Skip to content

Commit

Permalink
Adds --silence_qk_value option to elastalert
Browse files Browse the repository at this point in the history
This enables the user to silence a rule only for a specific query_key value and
not only the whole rule.
See elastalert Issue: Yelp#2777
  • Loading branch information
JasperJuergensen committed May 5, 2020
1 parent 52645c7 commit 294b6ed
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 5 additions & 0 deletions elastalert/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ def parse_args(cls, args) -> argparse.Namespace:
help="Silence rule for a time period. Must be used with --rule. Usage: "
"--silence <units>=<number>, eg. --silence hours=2",
)
parser.add_argument(
"--silence_qk_value",
dest="silence_qk_value",
help="Silence the rule only for this specific query key value.",
)
parser.add_argument(
"--start",
dest="start",
Expand Down
7 changes: 6 additions & 1 deletion elastalert/elastalert.py
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,12 @@ def silence(self, silence_cache_key=None):

first_rule = next(iter(self.rules.values()))
if not silence_cache_key:
silence_cache_key = first_rule["name"] + "._silence"
if config.CFG().args.silence_qk_value:
silence_cache_key = (
first_rule["name"] + config.CFG().args.silence_qk_value
)
else:
silence_cache_key = first_rule["name"] + "._silence"

try:
silence_ts = parse_deadline(config.CFG().args.silence)
Expand Down

0 comments on commit 294b6ed

Please sign in to comment.