-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[Incident management] Callout for alerts that triggered around the same time #223473
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
Merged
baileycash-elastic
merged 24 commits into
elastic:main
from
baileycash-elastic:alerting-213020
Jun 24, 2025
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
ebd88ab
start query
baileycash-elastic 3549b3a
add callout with alert count
baileycash-elastic ed4f074
route users to related alerts
baileycash-elastic 7f84fa8
fix docs
baileycash-elastic 1371d9b
Merge branch 'main' into alerting-213020
baileycash-elastic ed5d632
reposition callout
baileycash-elastic ccf976c
improvements, tab behavior fixes
baileycash-elastic 321464c
fix zero conditional
baileycash-elastic 34ad95c
add tests for callout
baileycash-elastic 55bc18d
consolidate queries
baileycash-elastic 09c05ba
rename query builder file
baileycash-elastic 005f509
add ui filter control
baileycash-elastic 0572a26
Merge branch 'main' into alerting-213020
baileycash-elastic 74a1e77
cleanup
baileycash-elastic c000c24
merge in main
baileycash-elastic 48d9a7f
error resolution
baileycash-elastic 5e84b43
update copy
baileycash-elastic d8db503
update copy for filter, separate filter into its own component
baileycash-elastic 881a390
Merge branch 'main' into alerting-213020
baileycash-elastic 8649528
Merge branch 'main' into alerting-213020
baileycash-elastic e6e5574
fix errors from merge conflict
baileycash-elastic 10a7ddc
change boolean name from useDefaultContext to skipReactQueryContext
baileycash-elastic 30e69a7
merge main into alerting-213020
baileycash-elastic 7c47b55
simplify tab switching based on recent changes from main
baileycash-elastic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
...lity/public/pages/alert_details/components/related_alerts/related_alerts_table_filter.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License | ||
| * 2.0; you may not use this file except in compliance with the Elastic License | ||
| * 2.0. | ||
| */ | ||
|
|
||
| import { EuiCheckbox, EuiFlexGroup, EuiFormRow, EuiPanel, EuiText } from '@elastic/eui'; | ||
| import React from 'react'; | ||
| import { i18n } from '@kbn/i18n'; | ||
| import { useFilterProximalParam } from '../../hooks/use_filter_proximal_param'; | ||
|
|
||
| export function RelatedAlertsTableFilter() { | ||
| const { filterProximal, setProximalFilterParam } = useFilterProximalParam(); | ||
|
|
||
| return ( | ||
| <EuiPanel paddingSize="m" hasShadow={false} color="subdued"> | ||
| <EuiFlexGroup direction="row" alignItems="center" justifyContent="flexStart"> | ||
| <EuiText size="s"> | ||
| <strong> | ||
| {i18n.translate('xpack.observability.alerts.relatedAlerts.filtersLabel', { | ||
| defaultMessage: 'Filters', | ||
| })} | ||
| </strong> | ||
| </EuiText> | ||
| <EuiFormRow fullWidth> | ||
| <EuiCheckbox | ||
| label={i18n.translate( | ||
| 'xpack.observability.alerts.relatedAlerts.proximityCheckboxLabel', | ||
| { | ||
| defaultMessage: 'Created around the same time', | ||
| } | ||
| )} | ||
| checked={filterProximal} | ||
| onChange={(event) => { | ||
| setProximalFilterParam(event.target.checked); | ||
| }} | ||
| id={'proximal-alerts-checkbox'} | ||
| data-test-subj="proximal-alerts-checkbox" | ||
| /> | ||
| </EuiFormRow> | ||
| </EuiFlexGroup> | ||
| </EuiPanel> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
...ility/plugins/observability/public/pages/alert_details/hooks/use_filter_proximal_param.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License | ||
| * 2.0; you may not use this file except in compliance with the Elastic License | ||
| * 2.0. | ||
| */ | ||
|
|
||
| import { useHistory, useLocation } from 'react-router-dom'; | ||
|
|
||
| export const useFilterProximalParam = () => { | ||
| const { search } = useLocation(); | ||
| const searchParams = new URLSearchParams(search); | ||
| const history = useHistory(); | ||
|
|
||
| const setProximalFilterParam = (proximalFilter: boolean) => { | ||
| searchParams.set('filterProximal', String(proximalFilter)); | ||
| history.replace({ search: searchParams.toString() }); | ||
| }; | ||
|
|
||
| const filterProximal = searchParams.get('filterProximal') === 'true'; | ||
|
|
||
| return { filterProximal, setProximalFilterParam }; | ||
| }; |
32 changes: 32 additions & 0 deletions
32
...bility/plugins/observability/public/pages/alert_details/hooks/use_find_proximal_alerts.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License | ||
| * 2.0; you may not use this file except in compliance with the Elastic License | ||
| * 2.0. | ||
| */ | ||
|
|
||
| import { useSearchAlertsQuery } from '@kbn/alerts-ui-shared/src/common/hooks/use_search_alerts_query'; | ||
| import { | ||
| OBSERVABILITY_RULE_TYPE_IDS_WITH_SUPPORTED_STACK_RULE_TYPES, | ||
| observabilityAlertFeatureIds, | ||
| } from '../../../../common/constants'; | ||
| import { AlertData } from '../../../hooks/use_fetch_alert_detail'; | ||
| import { useKibana } from '../../../utils/kibana_react'; | ||
| import { getBuildRelatedAlertsQuery } from './related_alerts/get_build_related_alerts_query'; | ||
|
|
||
| export const useFindProximalAlerts = (alertDetail: AlertData) => { | ||
| const { services } = useKibana(); | ||
|
|
||
| const esQuery = getBuildRelatedAlertsQuery({ | ||
| alert: alertDetail.formatted, | ||
| filterProximal: true, | ||
| }); | ||
|
|
||
| return useSearchAlertsQuery({ | ||
| data: services.data, | ||
| ruleTypeIds: OBSERVABILITY_RULE_TYPE_IDS_WITH_SUPPORTED_STACK_RULE_TYPES, | ||
| consumers: observabilityAlertFeatureIds, | ||
| query: esQuery, | ||
| skipAlertsQueryContext: true, | ||
| }); | ||
| }; |
42 changes: 42 additions & 0 deletions
42
...utions/observability/plugins/observability/public/pages/alert_details/hooks/use_tab_id.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License | ||
| * 2.0; you may not use this file except in compliance with the Elastic License | ||
| * 2.0. | ||
| */ | ||
|
|
||
| import { useHistory, useLocation } from 'react-router-dom'; | ||
|
|
||
| const ALERT_DETAILS_TAB_URL_STORAGE_KEY = 'tabId'; | ||
|
|
||
| export const useTabId = () => { | ||
| const { search } = useLocation(); | ||
| const history = useHistory(); | ||
|
|
||
| const getUrlTabId = () => { | ||
| const searchParams = new URLSearchParams(search); | ||
| return searchParams.get(ALERT_DETAILS_TAB_URL_STORAGE_KEY); | ||
| }; | ||
|
|
||
| const setUrlTabId = ( | ||
| tabId: string, | ||
| overrideSearchState?: boolean, | ||
| newSearchState?: Record<string, string> | ||
| ) => { | ||
| const searchParams = new URLSearchParams(overrideSearchState ? undefined : search); | ||
| searchParams.set(ALERT_DETAILS_TAB_URL_STORAGE_KEY, tabId); | ||
|
|
||
| if (newSearchState) { | ||
| Object.entries(newSearchState).forEach(([key, value]) => { | ||
| searchParams.set(key, value); | ||
| }); | ||
| } | ||
|
|
||
| history.replace({ search: searchParams.toString() }); | ||
| }; | ||
|
|
||
| return { | ||
| getUrlTabId, | ||
| setUrlTabId, | ||
| }; | ||
| }; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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: Destructuring an array so it becomes the exact arguments expected by the function feels brittle to me.
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 felt this was cleaner than having a conditional for the "same time" filter bool * (startDate + endDate) combinations