-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Response Ops][Alerting] Adding group by options to ES query rule type #144689
Conversation
…g/es-query-grouping
…g/es-query-grouping
…g/es-query-grouping
filter: [ | ||
...filterWithTime, | ||
{ | ||
match_all: {}, |
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.
not sure why this match_all
was in here, so removed.
@@ -12,12 +12,6 @@ import { DataPublicPluginStart } from '@kbn/data-plugin/public'; | |||
import { DataViewEditorStart } from '@kbn/data-view-editor-plugin/public'; | |||
import { EXPRESSION_ERRORS } from './constants'; | |||
|
|||
export interface Comparator { |
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.
this wasn't used anywhere
…g/es-query-grouping
…with showing existing rule params
…g/es-query-grouping
…g/es-query-grouping
@elasticmachine merge upstream |
@elasticmachine merge upstream |
@elasticmachine merge upstream |
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.
LGTM! Tested locally to verify the rules and migrations, and they work as expected.
@elasticmachine merge upstream |
…g/es-query-grouping
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.
LGTM - tested locally, works as expected.
I added a question on the migration, as it's technically not needed if we defaulted the values. More of a thinking exercise about future "rolling upgrade" migrations really ...
Also noted a check to see if the rule is grouping by checking the alert id, which will fail if the alert id for a grouped rule happens to equal the alert id we use for ungrouped rules. Seems like we can make that more robust.
...doc.attributes, | ||
params: { | ||
...doc.attributes.params, | ||
aggType: 'count', |
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.
Did we consider defaulting these fields, if not set in the params, to the values being set here? I can see in various places in the code where we are apply defaults for these, at least in the UX. I guess when referenced by the executorIt avoids migration, but ... kinda messy/sloppy?
It's certainly nice to have it very explicit, and don't have an issue with this migration - but am kinda wondering now with the "migration changes for rolling upgrades", if this pushes us in one direction or the other ...
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.
I did consider it but in the past we've always taken the approach of "explicit is better" so I went for the migration instead. Definitely something we'll have to consider harder with rolling upgrades though.
x-pack/plugins/stack_alerts/server/rule_types/es_query/executor.ts
Outdated
Show resolved
Hide resolved
.../stack_alerts/public/rule_types/es_query/rule_common_expressions/rule_common_expressions.tsx
Outdated
Show resolved
Hide resolved
...s/stack_alerts/public/rule_types/es_query/rule_common_expressions/threshold_help_popover.tsx
Outdated
Show resolved
Hide resolved
…g/es-query-grouping
Co-authored-by: Lisa Cawley <[email protected]>
…/kibana into alerting/es-query-grouping
💛 Build succeeded, but was flakyFailed CI StepsTest Failures
Metrics [docs]Module Count
Adoption-tracked APIs
Adoption-tracked APIs that are not used anywhere
Public APIs missing comments
Any counts in public APIs
Async chunks
Public APIs missing exports
Page load bundle
Saved Objects .kibana field count
Unknown metric groupsAPI count
async chunk count
ESLint disabled in files
ESLint disabled line counts
References to deprecated APIs
Total ESLint disabled count
Unreferenced deprecated APIs
History
To update your PR or re-run it, just comment with: cc @ymao1 |
Resolves #89481
Summary
Adds group by options to the ES query rule type, both DSL and KQL options. This is the same limited group by options that are offered in the index threshold rule type so I used the same UI components and rule parameter names. I moved some aggregation building code to
common
so they could be reused. All existing ES query rules are migrated to becount over all
rules.To Verify
count over all
rule - this should run the same as before, where it counts the number of documents that matches the query and applies the threshold condition to that value.{{context.hits}}
is all the documents that match the query if the threshold condition is met.<metric> over all
rule - this calculates the specific aggregation metric and applies the threshold condition to the aggregated metric (for example,avg event.duration
).{{context.hits}}
is all the documents that match the query if the threshold condition is met.count over top N terms
- this will apply a term aggregation to the query and matches the threshold condition to each term bucket (for example,count over top 10 event.action
will apply the threshold condition to the count of documents within eachevent.action
bucket).{{context.hits}}
is the result of the top hits aggregation within each term bucket if the threshold condition is met for that bucket.<metric> over top N terms
- this will apply a term aggregation and a metric sub-aggregation to the query and matches the threshold condition to the metric value within each term bucket (for example,avg event.duration over top 10 event.action
will apply the threshold condition to the average value ofevent.duration
within eachevent.action
bucket).{{context.hits}}
is the result of the top hits aggregation within each term bucket if the threshold condition is met for that bucket.Checklist