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

[Actionable Observability] Refactor alert search bar #143840

Merged

Conversation

maryam-saeidi
Copy link
Member

@maryam-saeidi maryam-saeidi commented Oct 24, 2022

Closes #142713

Summary

The following changes were applied to the search bar as a prerequisite to sharing this component via the triggers_action_ui plugin:

  1. Hide filters since they are not working currently and will be added in a separate ticket ([Actionable Observability] Alerts page > filter does not work #140573)
  2. Remove refreshNow logic and use absolute time in creating es query (discover also uses absolute time)
  3. Use already wired-up SearchBar provided by unified search (as suggested in [RAC] [Observability] Integrate the alerts search bar with the filter, query and time manager #116135)
  4. Save the status filter separate from the query input in the URL for easier separation between shared logic and custom implementation (In the future, we will use controls for extra filtering that will be provided by the unified search team)

How to test

  1. Go to Alerts page in Observability
  2. Make sure the alerts are shown correctly
  3. For active/recovered filter, time range and query input filter
    • It should filter alerts correctly
    • The filters should be saved in the URL correctly
    • By refreshing the page, the correct filter should be applied based on the URL query parameter

@maryam-saeidi maryam-saeidi added chore release_note:skip Skip the PR/issue when compiling release notes Team: Actionable Observability - DEPRECATED For Observability Alerting and SLOs use "Team:obs-ux-management", for AIops "Team:obs-knowledge" labels Oct 24, 2022
@maryam-saeidi maryam-saeidi marked this pull request as ready for review October 24, 2022 14:49
@maryam-saeidi maryam-saeidi requested review from a team as code owners October 24, 2022 14:49
@elasticmachine
Copy link
Contributor

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

Comment on lines -152 to -170
const setAlertStatusFilter = useCallback(
(id: string, query: string) => {
setAlertFilterStatus(id as AlertStatusFilterButton);
// Updating the KQL query bar alongside with user inputs is tricky.
// To avoid issue, this function always remove the AlertFilter and add it
// at the end of the query, each time the filter is added/updated/removed (Show All)
// NOTE: This (query appending) will be changed entirely: https://github.com/elastic/kibana/issues/116135
let output;
if (kuery === '') {
output = query;
} else {
const queryWithoutAlertFilter = kuery.replace(ALERT_STATUS_REGEX, '');
output = `${queryWithoutAlertFilter} and ${query}`;
}
onQueryChange({
dateRange: { from: rangeFrom, to: rangeTo },
// Clean up the kuery from unwanted trailing/ahead ANDs after appending and removing filters.
query: output.replace(/^\s*and\s*|\s*and\s*$/gm, ''),
});
Copy link
Contributor

Choose a reason for hiding this comment

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

👍🏻 so much cleaner

Copy link
Contributor

@formgeist formgeist left a comment

Choose a reason for hiding this comment

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

Design LGTM

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.

LGTM, good job @maryam-saeidi!

Tested locally, and works as expected 👍🏻
Screen Shot 2022-10-25 at 4 01 17 PM

Copy link
Contributor

@jcger jcger left a comment

Choose a reason for hiding this comment

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

LGTM 👏

@maryam-saeidi maryam-saeidi enabled auto-merge (squash) November 2, 2022 08:28
@maryam-saeidi maryam-saeidi enabled auto-merge (squash) November 2, 2022 09:53
@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
observability 552 553 +1

Async chunks

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

id before after diff
observability 491.7KB 491.6KB -105.0B
triggersActionsUi 652.9KB 652.8KB -62.0B
total -167.0B
Unknown metric groups

API count

id before after diff
observability 555 556 +1

ESLint disabled in files

id before after diff
osquery 1 2 +1

ESLint disabled line counts

id before after diff
enterpriseSearch 19 21 +2
fleet 57 63 +6
osquery 103 108 +5
securitySolution 439 445 +6
triggersActionsUi 132 131 -1
total +18

Total ESLint disabled count

id before after diff
enterpriseSearch 20 22 +2
fleet 65 71 +6
osquery 104 110 +6
securitySolution 516 522 +6
triggersActionsUi 135 134 -1
total +19

History

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

@maryam-saeidi maryam-saeidi merged commit 5c12624 into elastic:main Nov 2, 2022
@kibanamachine kibanamachine added v8.6.0 backport:skip This commit does not require backporting labels Nov 2, 2022
@maryam-saeidi maryam-saeidi deleted the 142713-refactor-alert-search-bar branch December 19, 2022 10:29
@maryam-saeidi maryam-saeidi self-assigned this Mar 23, 2023
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 chore release_note:skip Skip the PR/issue when compiling release notes Team: Actionable Observability - DEPRECATED For Observability Alerting and SLOs use "Team:obs-ux-management", for AIops "Team:obs-knowledge" v8.6.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Actionable Observability] Refactor AlertsSearchBar to create EsQuery internally
8 participants