-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[RAC] Get o11y alerts in alerts table #109346
Changes from all commits
bc3527a
80bc75c
f9c3928
dcb6c9d
3b18c32
c494512
53ab296
63f710d
f3f8aec
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,8 +7,10 @@ | |
|
||
import { EuiButtonEmpty, EuiCallOut, EuiFlexGroup, EuiFlexItem, EuiLink } from '@elastic/eui'; | ||
import { i18n } from '@kbn/i18n'; | ||
import React, { useCallback, useMemo, useRef } from 'react'; | ||
import React, { useCallback, useRef } from 'react'; | ||
import { useHistory } from 'react-router-dom'; | ||
import useAsync from 'react-use/lib/useAsync'; | ||
import { IndexPatternBase } from '@kbn/es-query'; | ||
import { ParsedTechnicalFields } from '../../../../rule_registry/common/parse_technical_fields'; | ||
import type { AlertWorkflowStatus } from '../../../common/typings'; | ||
import { ExperimentalBadge } from '../../components/shared/experimental_badge'; | ||
|
@@ -35,7 +37,7 @@ interface AlertsPageProps { | |
} | ||
|
||
export function AlertsPage({ routeParams }: AlertsPageProps) { | ||
const { core, ObservabilityPageTemplate } = usePluginContext(); | ||
const { core, plugins, ObservabilityPageTemplate } = usePluginContext(); | ||
const { prepend } = core.http.basePath; | ||
const history = useHistory(); | ||
const refetch = useRef<() => void>(); | ||
|
@@ -60,17 +62,41 @@ export function AlertsPage({ routeParams }: AlertsPageProps) { | |
// observability. For now link to the settings page. | ||
const manageRulesHref = prepend('/app/management/insightsAndAlerting/triggersActions/alerts'); | ||
|
||
const { data: dynamicIndexPatternResp } = useFetcher(({ signal }) => { | ||
const { data: indexNames = NO_INDEX_NAMES } = useFetcher(({ signal }) => { | ||
return callObservabilityApi({ | ||
signal, | ||
endpoint: 'GET /api/observability/rules/alerts/dynamic_index_pattern', | ||
params: { | ||
query: { | ||
namespace: 'default', | ||
registrationContexts: [ | ||
'observability.apm', | ||
'observability.logs', | ||
'observability.infrastructure', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this should be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TODO in the follow-up PR: remove |
||
'observability.metrics', | ||
'observability.uptime', | ||
], | ||
}, | ||
}, | ||
}); | ||
}, []); | ||
|
||
const dynamicIndexPattern = useMemo( | ||
() => (dynamicIndexPatternResp ? [dynamicIndexPatternResp] : []), | ||
[dynamicIndexPatternResp] | ||
); | ||
const dynamicIndexPatternsAsyncState = useAsync(async (): Promise<IndexPatternBase[]> => { | ||
if (indexNames.length === 0) { | ||
return []; | ||
} | ||
|
||
return [ | ||
{ | ||
id: 'dynamic-observability-alerts-table-index-pattern', | ||
title: indexNames.join(','), | ||
fields: await plugins.data.indexPatterns.getFieldsForWildcard({ | ||
pattern: indexNames.join(','), | ||
allowNoIndex: true, | ||
}), | ||
}, | ||
]; | ||
}, [indexNames]); | ||
|
||
const setWorkflowStatusFilter = useCallback( | ||
(value: AlertWorkflowStatus) => { | ||
|
@@ -165,7 +191,7 @@ export function AlertsPage({ routeParams }: AlertsPageProps) { | |
</EuiFlexItem> | ||
<EuiFlexItem> | ||
<AlertsSearchBar | ||
dynamicIndexPattern={dynamicIndexPattern} | ||
dynamicIndexPatterns={dynamicIndexPatternsAsyncState.value ?? NO_INDEX_PATTERNS} | ||
rangeFrom={rangeFrom} | ||
rangeTo={rangeTo} | ||
query={kuery} | ||
|
@@ -183,7 +209,7 @@ export function AlertsPage({ routeParams }: AlertsPageProps) { | |
|
||
<EuiFlexItem> | ||
<AlertsTableTGrid | ||
indexName={dynamicIndexPattern.length > 0 ? dynamicIndexPattern[0].title : ''} | ||
indexNames={indexNames} | ||
rangeFrom={rangeFrom} | ||
rangeTo={rangeTo} | ||
kuery={kuery} | ||
|
@@ -196,3 +222,6 @@ export function AlertsPage({ routeParams }: AlertsPageProps) { | |
</ObservabilityPageTemplate> | ||
); | ||
} | ||
|
||
const NO_INDEX_NAMES: string[] = []; | ||
const NO_INDEX_PATTERNS: IndexPatternBase[] = []; |
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.
@weltenwort Is there a way to get the space id from the UI? This may not always be
default
, no?We were pulling it off of the alerting framework rulesClient in the
rules/alerts/dynamic_index_pattern
route so we could ensure we acquired the correct space id on the request.. If observability doesn't plan on segmenting by space id I could understand why this would be hard coded todefault
then. Just looking for clarification here..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.
This is intentionally fixed as
default
, because in observability we're not using the space id in the namespace. The filtering by space happens as part of the RBAC filter if I saw that correctly.