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 KQL filtering in APM rules #163307

Closed

Conversation

benakansara
Copy link
Contributor

@benakansara benakansara commented Aug 7, 2023

Resolves https://github.com/elastic/apm-dev/issues/929

Adds KQL filtering to the following APM rules:

  • Latency threshold rule
  • Failed transaction rate rule
  • Error count threshold rule

KQL Filter ON

Screenshot 2023-07-31 at 16 45 13

KQL Filter OFF

Screenshot 2023-07-31 at 16 47 23

@benakansara benakansara self-assigned this Aug 7, 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.
  • /oblt-deploy-serverless : Deploy a serverless Kibana instance using the Observability test environments.
  • run elasticsearch-ci/docs : Re-trigger the docs validation. (use unformatted text in the comment!)

@benakansara benakansara added release_note:feature Makes this part of the condensed release notes Team: Actionable Observability - DEPRECATED For Observability Alerting and SLOs use "Team:obs-ux-management", for AIops "Team:obs-knowledge" v8.10.0 labels Aug 7, 2023
@benakansara benakansara marked this pull request as ready for review August 8, 2023 16:44
@benakansara benakansara requested a review from a team as a code owner August 8, 2023 16:44
@elasticmachine
Copy link
Contributor

Pinging @elastic/actionable-observability (Team: Actionable Observability)

@botelastic botelastic bot added the Team:APM All issues that need APM UI Team support label Aug 9, 2023
@elasticmachine
Copy link
Contributor

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

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.

Looks good. Only big caveat is the custom kql ui component. I was hoping this already existed. We already have unified search and have kql search for service groups (I cannot remember how that is implemented).

@benakansara benakansara requested a review from a team as a code owner August 11, 2023 08:51
@benakansara
Copy link
Contributor Author

Looks good. Only big caveat is the custom kql ui component. I was hoping this already existed. We already have unified search and have kql search for service groups (I cannot remember how that is implemented).

Refactored the code to reuse KQL filter related components from observability plugin. I looked into Unified Search component, but it has some additional functionalities like adding params to URL, calendar, refresh, etc. that we don't need for adding filter query in rule.

@sorenlouv
Copy link
Member

Thanks Bena!

@@ -91,7 +83,7 @@ export function MetricsExplorerKueryBar({
loadSuggestions={curryLoadSuggestions(loadSuggestions)}
onChange={handleChange}
onSubmit={onSubmit}
placeholder={placeholder || defaultPlaceholder}
placeholder={placeholder}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you please make the placeholder mandatory in the props (on line 30 of this file)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The placeholder can be empty sometimes, like in (even though it is set as ' ') -


Why do we want to make it mandatory?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I thought we had a default there to ensure we always have a placeholder, if there are valid cases that we don't want a placeholder, then having it optional is fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default placeholder was there with defaultPlaceholder which contained text Search for infrastructure data… (e.g. host.name:host-1). Since we need different placeholder text in Threshold and APM rules, I moved it to respective rule files, so there is no default place holder now.

Copy link
Member

@maryam-saeidi maryam-saeidi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AO changes LGTM!

I have a question overall about whether adding the KQL filter can cause confusion or not and what the expectation is for it.
For example, in the following case, I was able to add a filter for another service when adding the rule in the current service:

I think it will make the rule complicated, @benakansara is there any idea about how to avoid such cases?

return (
<ApmRuleParamsContainer
minimumWindowSize={{ value: 5, unit: TIME_UNITS.MINUTE }}
defaultParams={params}
fields={fields}
groupAlertsBy={groupAlertsBy}
kqlFilter={kqlFilter}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Can we make the space before Use KQL filter a bit less? (Maybe before and after of this component can have the same spacing?)

@@ -17,6 +17,8 @@ export const errorCountParamsSchema = schema.object({
environment: schema.string(),
groupBy: schema.maybe(schema.arrayOf(schema.string())),
errorGroupingKey: schema.maybe(schema.string()),
useKqlFilter: schema.maybe(schema.boolean()),
kqlFilter: schema.maybe(schema.string()),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@benakansara For the threshold rule, we use filterQuery as the field name, and here we have it as kqlFilter. Shall we use the same name for both rules? (Not sure which one to choose though 🤔 )

@benakansara
Copy link
Contributor Author

AO changes LGTM!

I have a question overall about whether adding the KQL filter can cause confusion or not and what the expectation is for it. For example, in the following case, I was able to add a filter for another service when adding the rule in the current service:

I think it will make the rule complicated, @benakansara is there any idea about how to avoid such cases?

@maryam-saeidi That's a good point. I think it is upto the user to add right filters. We have similar behaviour when creating a rule from "Hosts" view. Even though user has selected a host, and started creating a rule, they can add different hosts in filter. The difference is that the rule name is not auto-generated in this case.

@sqren What are your thoughts around this?

@maryam-saeidi
Copy link
Member

maryam-saeidi commented Aug 14, 2023

The difference is that the rule name is not auto-generated in this case.

Exactly, that's the difference that I see here. (Also the tags)

Maybe I am missing something but I didn't see the filtering for the host when I created a rule from a host page, do they add something host specific to the rule when it is created within a host page?

@benakansara benakansara requested review from a team as code owners August 14, 2023 13:29
@benakansara benakansara force-pushed the feat/add-kql-filtering-in-apm-rules branch 2 times, most recently from 4bd8292 to 87760ca Compare August 14, 2023 14:13
@shahzad31
Copy link
Contributor

Please close this and open a new PR if possible, this will keep pinging all the people, changing to draft doens't unsubs all the teams pinged

@benakansara
Copy link
Contributor Author

Please close this and open a new PR if possible, this will keep pinging all the people, changing to draft doens't unsubs all the teams pinged

@shahzad31 Sorry about that, something went wrong while merging to main. I have removed all the other teams from reviewers list, does it still ping them?

@kibana-ci
Copy link
Collaborator

kibana-ci commented Aug 14, 2023

💔 Build Failed

Failed CI Steps

Metrics [docs]

‼️ ERROR: metrics for e01c3e3 were not reported

History

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

cc @benakansara

@benakansara
Copy link
Contributor Author

@maryam-saeidi @sqren Opening a new PR as this one pinged many teams after merging to main. Removing teams from reviewers list doesn't unsubscribe them from notifications.
cc @shahzad31

benakansara added a commit that referenced this pull request Aug 15, 2023
Resolves elastic/apm-dev#929

Adds KQL filtering to the following APM rules:
- Latency threshold rule
- Failed transaction rate rule
- Error count threshold rule

### KQL Filter ON
<img width="598" alt="Screenshot 2023-07-31 at 16 45 13"
src="https://github.com/elastic/kibana/assets/69037875/277ac4c1-a542-4efe-bd0c-c2bccfac1a6c">

### KQL Filter OFF
<img width="602" alt="Screenshot 2023-07-31 at 16 47 23"
src="https://github.com/elastic/kibana/assets/69037875/f790ed56-d83d-4732-aa3e-4d7778926fbb">

### Note
Opening a new PR as #163307 pinged
many teams after merging to main. Removing teams from reviewers list
doesn't unsubscribe them from notifications.
hop-dev pushed a commit to hop-dev/kibana that referenced this pull request Aug 16, 2023
Resolves elastic/apm-dev#929

Adds KQL filtering to the following APM rules:
- Latency threshold rule
- Failed transaction rate rule
- Error count threshold rule

### KQL Filter ON
<img width="598" alt="Screenshot 2023-07-31 at 16 45 13"
src="https://github.com/elastic/kibana/assets/69037875/277ac4c1-a542-4efe-bd0c-c2bccfac1a6c">

### KQL Filter OFF
<img width="602" alt="Screenshot 2023-07-31 at 16 47 23"
src="https://github.com/elastic/kibana/assets/69037875/f790ed56-d83d-4732-aa3e-4d7778926fbb">

### Note
Opening a new PR as elastic#163307 pinged
many teams after merging to main. Removing teams from reviewers list
doesn't unsubscribe them from notifications.
bryce-b pushed a commit that referenced this pull request Aug 22, 2023
Resolves elastic/apm-dev#929

Adds KQL filtering to the following APM rules:
- Latency threshold rule
- Failed transaction rate rule
- Error count threshold rule

### KQL Filter ON
<img width="598" alt="Screenshot 2023-07-31 at 16 45 13"
src="https://github.com/elastic/kibana/assets/69037875/277ac4c1-a542-4efe-bd0c-c2bccfac1a6c">

### KQL Filter OFF
<img width="602" alt="Screenshot 2023-07-31 at 16 47 23"
src="https://github.com/elastic/kibana/assets/69037875/f790ed56-d83d-4732-aa3e-4d7778926fbb">

### Note
Opening a new PR as #163307 pinged
many teams after merging to main. Removing teams from reviewers list
doesn't unsubscribe them from notifications.
@benakansara benakansara deleted the feat/add-kql-filtering-in-apm-rules branch October 23, 2023 07:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release_note:feature Makes this part of the condensed release notes Team: Actionable Observability - DEPRECATED For Observability Alerting and SLOs use "Team:obs-ux-management", for AIops "Team:obs-knowledge" Team:APM All issues that need APM UI Team support v8.10.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants