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

Add group-by feature in APM rules #155001

Merged
merged 45 commits into from
Apr 25, 2023

Conversation

benakansara
Copy link
Contributor

@benakansara benakansara commented Apr 16, 2023

Summary

Adds group-by dropdown in the following APM rules.

  • APM Latency threshold (Preselected fields: service.name, service.environment, transaction.type)
  • APM Failed transaction rate (Preselected fields: service.name, service.environment, transaction.type)
  • APM Error count threshold (Preselected fields: service.name, service.environment)

Screenshot 2023-04-17 at 13 44 34

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

  • Updating the preview chart based on selected group by fields

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.

@benakansara benakansara added backport:skip This commit does not require backporting release_note:feature Makes this part of the condensed release notes v8.8.0 labels Apr 16, 2023
@benakansara benakansara self-assigned this Apr 16, 2023
@apmmachine
Copy link
Contributor

🤖 GitHub comments

Expand to view the GitHub comments

Just comment with:

  • /oblt-deploy : Deploy a Kibana instance using the Observability test environments.
  • run elasticsearch-ci/docs : Re-trigger the docs validation. (use unformatted text in the comment!)

@benakansara benakansara changed the title Add group by feature in APM rules Add group by options in APM rules Apr 17, 2023
@benakansara benakansara requested a review from a team April 17, 2023 09:01
@benakansara benakansara changed the title Add group by options in APM rules Add group-by feature in APM rules Apr 17, 2023
@benakansara benakansara marked this pull request as ready for review April 17, 2023 11:55
@benakansara benakansara requested a review from a team as a code owner April 17, 2023 11:55
@botelastic botelastic bot added the Team:APM All issues that need APM UI Team support label Apr 17, 2023
@elasticmachine
Copy link
Contributor

Pinging @elastic/apm-ui (Team:APM)

@benakansara
Copy link
Contributor Author

/oblt-deploy

@sorenlouv sorenlouv requested a review from kpatticha April 17, 2023 22:57
Copy link
Contributor

@kdelemme kdelemme left a 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

@benakansara
Copy link
Contributor Author

/oblt-deploy

@benakansara
Copy link
Contributor Author

/oblt-deploy

@benakansara
Copy link
Contributor Author

Hmm.. Yeah, you could do that. But alternatively you could hash the message like:

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;
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Contributor Author

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.

@benakansara
Copy link
Contributor Author

benakansara commented Apr 25, 2023

@dgieselaar @sqren
I am going to remove error.grouping_name entirely (UI, logic) for now. I will add it back when alert ID part is clear.

update: removed error.grouping_name related functionality

Copy link
Member

@sorenlouv sorenlouv left a 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!

@benakansara benakansara enabled auto-merge (squash) April 25, 2023 12:17
@benakansara benakansara disabled auto-merge April 25, 2023 12:26
@benakansara benakansara enabled auto-merge (squash) April 25, 2023 12:53
@benakansara benakansara merged commit ddd09ac into elastic:main Apr 25, 2023
@kibana-ci
Copy link
Collaborator

💛 Build succeeded, but was flaky

Failed CI Steps

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
apm 1322 1323 +1

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
apm 3.5MB 3.5MB +4.8KB

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
apm 32.3KB 32.3KB +10.0B
Unknown metric groups

ESLint disabled line counts

id before after diff
enterpriseSearch 17 19 +2
securitySolution 395 398 +3
total +5

Total ESLint disabled count

id before after diff
enterpriseSearch 18 20 +2
securitySolution 475 478 +3
total +5

History

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

cc @benakansara

Comment on lines +112 to +114
const allGroupbyFields = Array.from(
new Set([...predefinedGroupby, ...(ruleParams.groupBy ?? [])])
);
Copy link
Member

@sorenlouv sorenlouv Apr 26, 2023

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.

Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting release_note:feature Makes this part of the condensed release notes Team:APM All issues that need APM UI Team support v8.8.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants