]> 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>
Fri, 3 Jun 2022 09:55:42 +0000 (11:55 +0200)
Related to
Task #4943
Task #5179

(cherry picked from commit 877b32c1e42c6edde3fa5f6ab73293e0a4ad27c3)

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

index 428e7eebff293af0a01c1e770f6b7a51766604d8..2fa61d07bc81e2b739489f66615427f85b6fcdd5 100644 (file)
@@ -294,6 +294,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. */
@@ -813,6 +814,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 9b1b56117008f7df6ccea322ee6480ad96e784a7..6636a4a187563deb668bae9d55ccb21d6e1b9ac3 100644 (file)
@@ -369,7 +369,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 53e8d0c9cdfaa9e71fd52920406ee9c8878c582c..18668d07a9fbae65f5e25118ceb853a98e69d151 100644 (file)
@@ -2912,6 +2912,8 @@ TmEcode DetectEngineThreadCtxInit(ThreadVars *tv, void *initdata, void **data)
     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 d487a941ad3c64e7eed7817a7f0816f94ec444b1..b7380d9fcdb3574901619c9fd33879551bf0a333 100644 (file)
@@ -823,6 +823,7 @@ static DetectRunScratchpad DetectRunSetup(
 #ifdef UNITTESTS
     p->alerts.cnt = 0;
     p->alerts.discarded = 0;
+    p->alerts.suppressed = 0;
 #endif
     det_ctx->ticker++;
     det_ctx->filestore_cnt = 0;
@@ -935,6 +936,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 ba4283c06c81662ad421fd7915ae285523f09ac0..520d41446efba09543c7f6d2d4bc848189bd2772 100644 (file)
@@ -1045,8 +1045,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;