Skip to content

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

Merged
pmuellr merged 1 commit intoelastic:7.xfrom
pmuellr:backport/7.x/pr-60120
Mar 17, 2020
Merged

[7.x] [Alerting] apply group sorting on index threshold alert (#60120)#60351
pmuellr merged 1 commit intoelastic:7.xfrom
pmuellr:backport/7.x/pr-60120

Conversation

@pmuellr
Copy link
Copy Markdown
Contributor

@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 added the backport This PR is a backport of another PR label Mar 17, 2020
@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
Copy Markdown
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

backport This PR is a backport of another PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants