-
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
Add group-by feature in APM rules #155001
Add group-by feature in APM rules #155001
Conversation
🤖 GitHub commentsExpand to view the GitHub comments
Just comment with:
|
Pinging @elastic/apm-ui (Team:APM) |
/oblt-deploy |
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 a first pass, small neats. Going to tests further
x-pack/plugins/apm/public/components/alerting/ui_components/apm_rule_group_by.tsx
Show resolved
Hide resolved
...ck/plugins/apm/server/routes/alerts/rule_types/error_count/register_error_count_rule_type.ts
Outdated
Show resolved
Hide resolved
/oblt-deploy |
/oblt-deploy |
…/register_error_count_rule_type.ts Co-authored-by: Søren Louv-Jansen <[email protected]>
I am fine with either way (removing for now or using hash). My only concern is that if we need more discussion around alert ID, we should wait till it is clear. |
@@ -88,6 +88,9 @@ export function registerErrorCountRuleType({ | |||
minimumLicenseRequired: 'basic', | |||
isExportable: true, | |||
executor: async ({ params: ruleParams, services, spaceId }) => { | |||
const predefinedGroupby = [SERVICE_NAME, SERVICE_ENVIRONMENT]; | |||
const allGroupbyFields = ruleParams.groupBy ?? predefinedGroupby; |
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.
Does this mean that users can (maybe theoretically?) force the rule to not use service.name
and service.environment
as grouping keys?
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.
No. This check is to support existing rules when upgrading Kibana since groupBy
was not present before so it's value will be undefined. If user opens the rule in UI and saves it, this will be updated.
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.
Users can (and do) use the API directly though. I think these kinds of things should ideally be in the server. Part of it in the browser and part of it in the server is a bit risky IMHO. But not a blocker.
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 see, I have updated the code to always include predefined group-by fields.
...ck/plugins/apm/server/routes/alerts/rule_types/error_count/register_error_count_rule_type.ts
Show resolved
Hide resolved
@dgieselaar @sqren update: removed |
x-pack/test/apm_api_integration/tests/alerts/transaction_error_rate.spec.ts
Outdated
Show resolved
Hide resolved
x-pack/test/apm_api_integration/tests/alerts/transaction_duration.spec.ts
Outdated
Show resolved
Hide resolved
x-pack/test/apm_api_integration/tests/alerts/transaction_error_rate.spec.ts
Show resolved
Hide resolved
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.
Just a few nits left. LGTM and thanks for all the help!
APM alerting is improving rapidly these days!
x-pack/test/apm_api_integration/tests/alerts/error_count_threshold.spec.ts
Outdated
Show resolved
Hide resolved
💛 Build succeeded, but was flaky
Failed CI StepsMetrics [docs]Module Count
Async chunks
Page load bundle
Unknown metric groupsESLint disabled line counts
Total ESLint disabled count
History
To update your PR or re-run it, just comment with: cc @benakansara |
const allGroupbyFields = Array.from( | ||
new Set([...predefinedGroupby, ...(ruleParams.groupBy ?? [])]) | ||
); |
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.
nit: with lodash this can be simplified like:
const allGroupbyFields = union(predefinedGroupBy, ruleParams.groupBy)
(also: there is a consistency with "group by". Sometimes it's written as "groupby" other times as "groupBy". I suggest we consistently use the latter.
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 will address this in a new PR.
Summary
Adds group-by dropdown in the following APM rules.
service.name
,service.environment
,transaction.type
)service.name
,service.environment
,transaction.type
)service.name
,service.environment
)The preselected fields cannot be removed by user. The
transaction.name
field is selectable by user from the group-by dropdown.Reason message is updated to include group key instead of only service name:
The
transaction.name
is added to the alert document:The
transaction.name
action variable is added in UI:The
transaction.name
is added to the context of active alert notifications:There is an additional field in group-by dropdown for Error count threshold rule: #155633
error.grouping_key
Fixes
Update on Alert Id
The alert Id is updated for all 3 rules. The new Id is generated from the group key. This is to avoid issues similar to #154818 where alerts are scheduled with same ID. Example of the new alert Ids -
opbeans-java_development_request_GET /flaky
,opbeans-java_development_GET /fail
Out of scope of this PR
Checklist
Release note
As the alert Id is updated for the APM Latency threshold rule, APM Failed transaction rate rule and APM Error count rule, the existing alerts, if any, will be recovered, and new alerts will be fired in place of them.