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

feat(investigation): Add eventTypes filter on the API #202829

Merged
merged 19 commits into from
Dec 12, 2024

Conversation

kdelemme
Copy link
Contributor

@kdelemme kdelemme commented Dec 3, 2024

Resolves #200800

🏇🏻 Summary

Note

I've implemented a basic UI selector using the existing EuiFilterGroup instead of the Figma UI that requires a more custom component. We can always iterate later.

This PR adds an optional eventTypes filter on the observability events API. The eventTypes string is checked against the event type enum, and transformed to an array for easier usage within the boundary of the server.
When no specified, all event types are returned.

🍰 Boy/Girl scouts rule: I've also refactored/cleaned a few shenanigans I've introduced a while back in the Investigation context instead of leveraging react query context directly.

Screenshots
image
rca_filter_events.mov

@kdelemme kdelemme force-pushed the investigate/add-filter branch from b2b96d0 to 6cff219 Compare December 4, 2024 20:43
@kdelemme kdelemme added release_note:skip Skip the PR/issue when compiling release notes backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) Team:obs-ux-management Observability Management User Experience Team v8.18.0 labels Dec 4, 2024
@kdelemme kdelemme self-assigned this Dec 4, 2024
@kdelemme kdelemme marked this pull request as ready for review December 4, 2024 20:51
@kdelemme kdelemme requested a review from a team as a code owner December 4, 2024 20:51
@elasticmachine
Copy link
Contributor

Pinging @elastic/obs-ux-management-team (Team:obs-ux-management)

@botelastic botelastic bot added the ci:project-deploy-observability Create an Observability project label Dec 4, 2024
Copy link
Contributor

github-actions bot commented Dec 4, 2024

🤖 GitHub comments

Expand to view the GitHub comments

Just comment with:

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

@fkanout fkanout self-requested a review December 11, 2024 09:59
@@ -8,7 +8,7 @@
*/

import { z } from '@kbn/zod';
Copy link
Contributor

Choose a reason for hiding this comment

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

What is this none self-explanatory z 🤔 😆 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Did I add that? I don't recall importing from @kbn/zod but that's probably just a wrapper around zod itself

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

I didn't know it before. Thanks!

Copy link
Contributor

@fkanout fkanout left a comment

Choose a reason for hiding this comment

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

I'm not sure if it's related to the PR OR if this could be fixed in it, but the page is not fully responsive.
Screenshot 2024-12-11 at 11 20 33


if (
annotationsClient &&
(includeAllEventTypes || params?.query?.eventTypes?.includes('annotation'))
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder how robust is this check params?.query?.eventTypes?.includes('annotation'))? Do we have another way to check this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Zod ensures that if eventTypes is present on the query parameters, then it is an array of event type (enum).

I could write the same check as params && params.query && params.query.eventTypes && params.queryEventTypes.includes('annotation') but I would be reinventing optional chaining. I don't think it's more readable this way, but it's definitely more verbose 😅

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@fkanout Do you want me to address this somehow?

Copy link
Contributor

Choose a reason for hiding this comment

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

@kdelemme thank you for explaining it; it's more clear now. My only concern is the hard-coded string annotation type. If it's an enum, I would expect to use it instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah yes good point. I forgot to parse the eventTypes: ac24d91

alignItems="flexStart"
justifyContent="spaceBetween"
responsive
css={css`
Copy link
Contributor

Choose a reason for hiding this comment

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

Out of curiosity, why do we use the css emotion in this inline style instead of the built-in style?

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 tend to use it all the time, just in case I need to write nested selectors. But true it is not needed here, and style would work the same

@kdelemme
Copy link
Contributor Author

Going to check the responsiveness, good catch

@kdelemme
Copy link
Contributor Author

@fkanout The responsiveness is already broken on main, I'm going to open a few tickets to keep track of these things

onEventTypesSelected: (eventTypes: string[]) => void;
}

export function InvestigationTimelineFilterBar({ onEventTypesSelected }: Props) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

💬 Simplified (and renamed) the timeline filter bar: replaced uiSearch with dateRange eui component and moved the update function into here.

onSelected: (eventTypes: string[]) => void;
}

export function InvestigationEventTypesFilter({ onSelected }: Props) {
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 event filter dropdown component

Copy link
Contributor

@fkanout fkanout left a comment

Choose a reason for hiding this comment

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

LGTM. 💪🏻
@kdelemme leave it to you how to handle the annotation enum if you think there is a better way. And to solve the merge conficlts.

@kdelemme kdelemme enabled auto-merge (squash) December 12, 2024 15:00
@elasticmachine
Copy link
Contributor

⏳ Build in-progress

  • Buildkite Build
  • Commit: cf33ccc
  • Kibana Serverless Image: docker.elastic.co/kibana-ci/kibana-serverless:pr-202829-cf33ccc6a858

History

cc @kdelemme

@kdelemme kdelemme merged commit 2ab38a3 into elastic:main Dec 12, 2024
8 checks passed
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.x

https://github.com/elastic/kibana/actions/runs/12300981413

@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.x

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Dec 12, 2024
…#204089)

# Backport

This will backport the following commits from `main` to `8.x`:
- [feat(investigation): Add eventTypes filter on the API
(#202829)](#202829)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Kevin
Delemme","email":"kevin.delemme@elastic.co"},"sourceCommit":{"committedDate":"2024-12-12T16:49:34Z","message":"feat(investigation):
Add eventTypes filter on the API
(#202829)","sha":"2ab38a3664cf7f103ac1a57f664c736a8e3d495b","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","backport:prev-minor","ci:project-deploy-observability","Team:obs-ux-management","v8.18.0"],"title":"feat(investigation):
Add eventTypes filter on the
API","number":202829,"url":"https://github.com/elastic/kibana/pull/202829","mergeCommit":{"message":"feat(investigation):
Add eventTypes filter on the API
(#202829)","sha":"2ab38a3664cf7f103ac1a57f664c736a8e3d495b"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/202829","number":202829,"mergeCommit":{"message":"feat(investigation):
Add eventTypes filter on the API
(#202829)","sha":"2ab38a3664cf7f103ac1a57f664c736a8e3d495b"}},{"branch":"8.x","label":"v8.18.0","branchLabelMappingKey":"^v8.18.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Kevin Delemme <kevin.delemme@elastic.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) ci:project-deploy-observability Create an Observability project release_note:skip Skip the PR/issue when compiling release notes Team:obs-ux-management Observability Management User Experience Team v8.18.0 v9.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[RCA Initiative] Events timeline filter system is in place
4 participants