From 9e32b69d977c229ca9d3cc3188c1238aae879db1 Mon Sep 17 00:00:00 2001 From: Kevin Delemme Date: Fri, 24 May 2024 09:45:14 -0400 Subject: [PATCH] feat(slo): show instance details in slo alert page (#184051) --- .../alert_details_app_section.tsx | 26 ++++++++++++++----- .../slos/components/common/slo_groupings.tsx | 17 ++++++++---- .../compact_view/slo_list_compact_view.tsx | 2 +- 3 files changed, 33 insertions(+), 12 deletions(-) diff --git a/x-pack/plugins/observability_solution/slo/public/components/slo/burn_rate/alert_details/alert_details_app_section.tsx b/x-pack/plugins/observability_solution/slo/public/components/slo/burn_rate/alert_details/alert_details_app_section.tsx index 8358d897cd7b1..324c84c9d923f 100644 --- a/x-pack/plugins/observability_solution/slo/public/components/slo/burn_rate/alert_details/alert_details_app_section.tsx +++ b/x-pack/plugins/observability_solution/slo/public/components/slo/burn_rate/alert_details/alert_details_app_section.tsx @@ -6,12 +6,14 @@ */ import { EuiFlexGroup, EuiLink } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import React, { useEffect } from 'react'; import { AlertSummaryField } from '@kbn/observability-plugin/public'; -import { useKibana } from '../../../../utils/kibana_react'; +import { ALL_VALUE } from '@kbn/slo-schema'; +import React, { useEffect } from 'react'; import { useFetchSloDetails } from '../../../../hooks/use_fetch_slo_details'; -import { ErrorRatePanel } from './components/error_rate/error_rate_panel'; +import { SLOGroupings } from '../../../../pages/slos/components/common/slo_groupings'; +import { useKibana } from '../../../../utils/kibana_react'; import { CustomAlertDetailsPanel } from './components/custom_panels/custom_panels'; +import { ErrorRatePanel } from './components/error_rate/error_rate_panel'; import { BurnRateAlert, BurnRateRule } from './types'; interface AppSectionProps { @@ -40,7 +42,7 @@ export default function AlertDetailsAppSection({ const alertLink = alert.link; useEffect(() => { - setAlertSummaryFields([ + const fields = [ { label: i18n.translate('xpack.slo.burnRateRule.alertDetailsAppSection.summaryField.slo', { defaultMessage: 'Source SLO', @@ -61,8 +63,20 @@ export default function AlertDetailsAppSection({ ), }, - ]); - }, [alertLink, rule, ruleLink, setAlertSummaryFields, basePath, slo]); + ]; + + if (instanceId !== ALL_VALUE) { + fields.push({ + label: i18n.translate( + 'xpack.slo.burnRateRule.alertDetailsAppSection.summaryField.instanceId', + { defaultMessage: 'SLO Instance' } + ), + value: , + }); + } + + setAlertSummaryFields(fields); + }, [alertLink, rule, ruleLink, setAlertSummaryFields, basePath, slo, instanceId]); return ( diff --git a/x-pack/plugins/observability_solution/slo/public/pages/slos/components/common/slo_groupings.tsx b/x-pack/plugins/observability_solution/slo/public/pages/slos/components/common/slo_groupings.tsx index b61d1edc5ed93..902e46d549e5b 100644 --- a/x-pack/plugins/observability_solution/slo/public/pages/slos/components/common/slo_groupings.tsx +++ b/x-pack/plugins/observability_solution/slo/public/pages/slos/components/common/slo_groupings.tsx @@ -22,10 +22,11 @@ import { SLOWithSummaryResponse } from '@kbn/slo-schema'; export interface Props { slo: SLOWithSummaryResponse | undefined; direction?: 'column' | 'row'; + gutterSize?: 'none' | 's'; truncate?: boolean; } -export function SLOGroupings({ slo, direction = 'row', truncate = true }: Props) { +export function SLOGroupings({ slo, direction = 'row', gutterSize = 's', truncate = true }: Props) { const groups = Object.entries(slo?.groupings || []); const shouldTruncate = truncate && groups.length > 3; const firstThree = shouldTruncate ? groups.slice(0, 3) : groups; @@ -59,7 +60,7 @@ export function SLOGroupings({ slo, direction = 'row', truncate = true }: Props) direction={direction} > - {' '} + {rest.length && ( @@ -80,12 +81,16 @@ export function SLOGroupings({ slo, direction = 'row', truncate = true }: Props) } > - + ) : ( - + )} ); @@ -94,14 +99,16 @@ export function SLOGroupings({ slo, direction = 'row', truncate = true }: Props) function Entries({ entries, direction, + gutterSize = 's', }: { entries: Array<[string, unknown]>; direction: 'row' | 'column'; + gutterSize?: 'none' | 's'; }) { const { euiTheme } = useEuiTheme(); return ( - + {entries.map(([key, value]) => ( diff --git a/x-pack/plugins/observability_solution/slo/public/pages/slos/components/compact_view/slo_list_compact_view.tsx b/x-pack/plugins/observability_solution/slo/public/pages/slos/components/compact_view/slo_list_compact_view.tsx index 64685a943ce38..d773d56ac47f8 100644 --- a/x-pack/plugins/observability_solution/slo/public/pages/slos/components/compact_view/slo_list_compact_view.tsx +++ b/x-pack/plugins/observability_solution/slo/public/pages/slos/components/compact_view/slo_list_compact_view.tsx @@ -349,7 +349,7 @@ export function SloListCompactView({ sloList, loading, error }: Props) { render: (_, slo: SLOWithSummaryResponse) => { const groups = [slo.groupBy].flat(); return !groups.includes(ALL_VALUE) ? ( - + ) : ( {NOT_AVAILABLE_LABEL} );