Skip to content
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 a bug where realert doesnt respect query_key when using flatline #1179

Merged
merged 3 commits into from
Jun 22, 2017

Conversation

Qmando
Copy link
Member

@Qmando Qmando commented Jun 21, 2017

Fixes #1177

This is a hacky fix, but I don't want to break backwards compatibility, at least not yet. Flatline + query_key has been using this "key" field forever.

See https://github.com/Yelp/elastalert/blob/master/elastalert/ruletypes.py#L527

@@ -686,6 +687,9 @@ def get_segment_size(self, rule):

def get_query_key_value(self, rule, match):
# get the value for the match's query_key (or none) to form the key used for the silence_cache.
# Flatline ruletype sets "key" instead of the actual query_key
if isinstance(rule['type'], FlatlineRule) and 'key' in match:
return match['key']
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should still go through get_named_key_value, but pass key instead of query_key, so that you can get the benefits that come with it (unicode stuff, using lookup_es_key for better handling of complex keys)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get_named_key_value won't work for this. It takes a key name then looks up the value of that key in the rule. Passing 'query_key' might return rule['username'] for example. I will add a unicode( ) though.

@Qmando Qmando merged commit f5ec9e7 into master Jun 22, 2017
@Qmando Qmando deleted the fix_flatline_realert_qk branch October 16, 2017 19:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rule with flatline and use_terms_query doesn't work anymore after elastalert upgrade (->v0.1.12)
2 participants