-
Notifications
You must be signed in to change notification settings - Fork 297
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix compound query key in metric aggregation with bucket_interval #71
Conversation
the pr in the upstream Yelp/elastalert#3161 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution. I see some related tests in tests/rules_test.py
, specifically test_base_aggregation_payloads()
. Would be good to see some coverage added for this scenario.
Could this solution works for percentage_match? |
Good question. It looks unrelated but there could be something I'm not seeing. The submitter hasn't responded to the unit test topic. If anyone else needs this change merged, please add a quick unit test to the existing rules_test.py, and I'll merge it in. |
@jertel PTAL, I've just got some spare time to look into this, sorry for the long delay. @mrfroggg I checked your commented issue and the code in Yelp#2133, few things I have noticed
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contributions @just1900
Fix metric aggregation while using compound query key and bucket_interval together
What happened here
metric_aggregation
, compoundquery_key
andbucket_interval
like below.the
payload_data
param in function add_aggregation_data will contain compoundbucket_aggs
key looks like below https://github.com/jertel/elastalert/blob/c8949c1e715ca0b9b5b923a5e3625c52163a4068/elastalert/ruletypes.py#L1034-L1041then after indexing https://github.com/jertel/elastalert/blob/c8949c1e715ca0b9b5b923a5e3625c52163a4068/elastalert/ruletypes.py#L1039 and unwarp_term_bucket https://github.com/jertel/elastalert/blob/c8949c1e715ca0b9b5b923a5e3625c52163a4068/elastalert/ruletypes.py#L1048-L1053
the
aggregation_data
param in function check_matches looks likeWhat we could see is that the
interval_aggs
key is not unwrapped here. Also, the functioncheck_matches_recursive
only unwrapbucket_aggs
recursively.https://github.com/jertel/elastalert/blob/c8949c1e715ca0b9b5b923a5e3625c52163a4068/elastalert/ruletypes.py#L1112-L1127
So if the
bucket_interval
is configured in the rules, and line 1127 will run into the KeyError while indexingself.metric_key
.How to Fix it
interval_aggs
key in functioncheck_matches_recursive