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

Clickhouse changes #1

Open
wants to merge 13 commits into
base: alertmanager_alerter
Choose a base branch
from
Open

Conversation

sanyamjain22
Copy link
Collaborator

No description provided.

@@ -534,43 +540,57 @@ def get_hits_terms(self, rule, starttime, endtime, index, key, qk=None, size=Non
return {endtime: buckets}

def get_hits_aggregation(self, rule, starttime, endtime, index, query_key, term_size=None):
Copy link
Collaborator

@sivatarunp sivatarunp Mar 17, 2022

Choose a reason for hiding this comment

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

You are changing the common method being used, so I think it will effect the existing alerts? Can you check?
Also is this required just for response_time alert

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

in traces use case it will be used only for response time avg alert. As we already discussed we will host elastalert for trace separately from logs, this should not be an issue

if term_size is None:
term_size = rule.get('terms_size', 50)
query = self.get_aggregation_query(base_query, rule, query_key, term_size, rule['timestamp_field'])
agg_key = rule['metric_agg_type']+"("+rule['metric_agg_key']+")"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a better way to do string interpolation and concatenation in Python. In Python 3, We can do like thisf'{var}'

term_size = rule.get('terms_size', 50)
query = self.get_aggregation_query(base_query, rule, query_key, term_size, rule['timestamp_field'])
agg_key = rule['metric_agg_type']+"("+rule['metric_agg_key']+")"
query = rule['filter'][0]['query_string']['query']
Copy link
Collaborator

Choose a reason for hiding this comment

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

What if there is no filter? Will config itself throw that error or will it get stuck here?

def __init__(self, *args):
super(ErrorRateRule, self).__init__(*args)
self.ts_field = self.rules.get('timestamp_field', '@timestamp')
self.rules['metric_agg_key'] = "1"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this default? Shall we add a comment here as this is default?

return {}

payload = {'error_count': error_data, 'total_count': total_data}
self.num_hits += int(total_count)
Copy link
Collaborator

Choose a reason for hiding this comment

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

why num_hits is required?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

num hits is mainly used in looping very large dataset in batches using scroll in ES. Also it appears in the alert. Updating it to follow the convention followed across the code

return {endtime: payload}
return None,0
res = json.loads(res.content)
return res['data'][0][agg_key], res['rows']
Copy link
Collaborator

Choose a reason for hiding this comment

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

What would be there in these two values?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

agg value and the number of rows satisfied the filter criteria

super(ErrorRateRule, self).__init__(*args)
self.ts_field = self.rules.get('timestamp_field', '@timestamp')
self.rules['metric_agg_key'] = "1"
self.rules['metric_agg_type'] = "count"
Copy link
Collaborator

Choose a reason for hiding this comment

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

We need to have cardinality query when finding total traces and just count query for error_traces? So metric_agg_type should be cardinality. But it's going as count only by default.

Copy link
Collaborator

@RashmiRam RashmiRam left a comment

Choose a reason for hiding this comment

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

👍

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.

3 participants