fix(plugins/rule-flood-guard): scope flood threshold per rule and data source#2368
Merged
yllada merged 2 commits intoJul 22, 2026
Merged
Conversation
✅ AI review — CleanNo issues detected in this diff. ✅
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Changes how
rule-flood-guardcounts alerts before deciding to auto-disable a rule: the threshold now applies per (rule, data source) pair instead of per rule globally.Why
The original counting logic grouped alerts only by rule name. This meant a rule firing legitimately once each across many different data sources/assets (e.g. the same detection catching a real, spreading incident on 50 different endpoints) could cross the threshold and get auto-disabled — exactly the wrong moment to lose that detection. Grouping by rule and data source correctly distinguishes "the same signal repeating without dedup on one source" (real fatigue) from "the same rule legitimately firing across many distinct sources" (not fatigue).
Changes
aggregation.go: the OpenSearch query now nests adataSource.keywordterms sub-aggregation inside the existingname.keywordterms aggregation (size 10000 for the inner level, mirroring the existingmaxSourceBucketsconvention inbackend/modules/datasources/repository/stats_os.go).ruleBucketgained aDataSourcefield; parsing walks both levels into a flat list.guard.go: the threshold check and log context now operate per (rule, data source) pair. Disabling a rule and sending the notification are unchanged — a rule is still a single global toggle.backend.go: the notification message now names the specific data source that tripped the threshold, so the analyst knows where to look first.README.md: updated to describe the per-(rule, data source) counting semantics.