]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
detect/stats: log out total of suppressed alerts
authorJuliana Fajardini <jufajardini@gmail.com>
Wed, 20 Apr 2022 16:49:31 +0000 (13:49 -0300)
committerVictor Julien <vjulien@oisf.net>
Sat, 30 Apr 2022 05:58:39 +0000 (07:58 +0200)
Related to
Task #4943
Task #5179

src/decode.h
src/detect-engine-alert.c
src/detect-engine.c
src/detect.c
src/detect.h

index 725a99cc56c40f78a07eca44787a2b45b88617fa..3d1323fec76a1672a54a179fc4b6e66cacc8fbef 100644 (file)
@@ -305,6 +305,7 @@ extern uint16_t packet_alert_max;
 typedef struct PacketAlerts_ {
     uint16_t cnt;
     uint16_t discarded;
+    uint16_t suppressed;
     PacketAlert *alerts;
     /* single pa used when we're dropping,
      * so we can log it out in the drop log. */
@@ -841,6 +842,7 @@ void CaptureStatsSetup(ThreadVars *tv, CaptureStats *s);
         (p)->pktlen = 0;                                                                           \
         (p)->alerts.cnt = 0;                                                                       \
         (p)->alerts.discarded = 0;                                                                 \
+        (p)->alerts.suppressed = 0;                                                                \
         (p)->alerts.drop.action = 0;                                                               \
         (p)->pcap_cnt = 0;                                                                         \
         (p)->tunnel_rtv_cnt = 0;                                                                   \
index 45495b667dcf1e9e4bdb2d923f8ecca2a99b497f..2f74ed4fcfba6372bc6ccb4751042805718a98f8 100644 (file)
@@ -371,7 +371,7 @@ void PacketAlertFinalize(DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx
         /* Thresholding removes this alert */
         if (res == 0 || res == 2 || (s->flags & SIG_FLAG_NOALERT)) {
             /* we will not copy this to the AlertQueue */
-            p->alerts.discarded++;
+            p->alerts.suppressed++;
         } else if (p->alerts.cnt < packet_alert_max) {
             p->alerts.alerts[p->alerts.cnt] = det_ctx->alert_queue[i];
             SCLogDebug("Appending sid %" PRIu32 " alert to Packet::alerts at pos %u", s->id, i);
index d6018b17476ac8de21777d776e73fddaf8011e84..07181181d9d1457759fc2a3d86665a5eb468b407 100644 (file)
@@ -3174,6 +3174,7 @@ TmEcode DetectEngineThreadCtxInit(ThreadVars *tv, void *initdata, void **data)
     /** alert counter setup */
     det_ctx->counter_alerts = StatsRegisterCounter("detect.alert", tv);
     det_ctx->counter_alerts_overflow = StatsRegisterCounter("detect.alert_queue_overflow", tv);
+    det_ctx->counter_alerts_suppressed = StatsRegisterCounter("detect.alerts_suppressed", tv);
 #ifdef PROFILING
     det_ctx->counter_mpm_list = StatsRegisterAvgCounter("detect.mpm_list", tv);
     det_ctx->counter_nonmpm_list = StatsRegisterAvgCounter("detect.nonmpm_list", tv);
index 4946b75e67257b77b2e9ae888dd95b6e230d2bf7..17502da16c38e5b6662c7d6f0a42048aa62e2359 100644 (file)
@@ -829,6 +829,7 @@ static DetectRunScratchpad DetectRunSetup(
 #ifdef UNITTESTS
     p->alerts.cnt = 0;
     p->alerts.discarded = 0;
+    p->alerts.suppressed = 0;
 #endif
     det_ctx->filestore_cnt = 0;
     det_ctx->base64_decoded_len = 0;
@@ -940,6 +941,9 @@ static inline void DetectRunPostRules(
     if (p->alerts.discarded > 0) {
         StatsAddUI64(tv, det_ctx->counter_alerts_overflow, (uint64_t)p->alerts.discarded);
     }
+    if (p->alerts.suppressed > 0) {
+        StatsAddUI64(tv, det_ctx->counter_alerts_suppressed, (uint64_t)p->alerts.suppressed);
+    }
     PACKET_PROFILING_DETECT_END(p, PROF_DETECT_ALERT);
 }
 
index 42e2fbdccbaecf8fabb310dffa142a86cec49bb3..3f85e03dbf6d5b5eb5b9583d94b53e5ea4d89eea 100644 (file)
@@ -1094,8 +1094,10 @@ typedef struct DetectEngineThreadCtx_ {
 
     /** id for alert counter */
     uint16_t counter_alerts;
-    /** id for discarded alerts counter**/
+    /** id for discarded alerts counter */
     uint16_t counter_alerts_overflow;
+    /** id for suppressed alerts counter */
+    uint16_t counter_alerts_suppressed;
 #ifdef PROFILING
     uint16_t counter_mpm_list;
     uint16_t counter_nonmpm_list;