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

[7.x] [Alerting] apply group sorting on index threshold alert (#60120) #60351

Merged
merged 1 commit into from
Mar 17, 2020

Conversation

pmuellr
Copy link
Member

@pmuellr pmuellr commented Mar 17, 2020

The current index threshold alert uses a `size` limit on term aggregation, when used, but does not sort the buckets, so it's just using descending count on the grouped buckets as the sort to determine what to return.

The watcher API for the index threshold notes this as "top N of", implying a sort.

This PR applies sorting when the using `groupBy: top`, and the `aggType != count`.  For count, ES is already sorting the way we want.

The sort is calculated as a separate agg beside the date_range aggregation, which is the same metrics agg specified in the query - `aggType(aggField)`.  This field is then referenced in a new `order` property in the terms agg, using 'asc' sorting for `min`, and `desc` sorting for `avg`, `max`, and `sum`.

This doesn't change the shape of the output at all, just changes which term buckets will be returned, if there are more term buckets than requested with the `termSize` parameter.
@pmuellr pmuellr changed the title [7.x] resolves https://github.com/elastic/kibana/issues/58905 (#60120) [Alerting] apply group sorting on index threshold alert (#60120) Mar 17, 2020
@kibanamachine
Copy link
Contributor

💚 Build Succeeded

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@pmuellr pmuellr changed the title [Alerting] apply group sorting on index threshold alert (#60120) [7.x] [Alerting] apply group sorting on index threshold alert (#60120) Mar 17, 2020
@pmuellr pmuellr merged commit c667afa into elastic:7.x Mar 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants