From 44ab1ee065df81598c69e4dd074bc8bfb3f0ff95 Mon Sep 17 00:00:00 2001 From: Alex Fedotyev <61838744+alex-fedotyev@users.noreply.github.com> Date: Tue, 24 Nov 2026 15:51:21 +0000 Subject: [PATCH] feat(app): grouped SLOs in the list and on the SLO page A grouped SLO expands into its tracked groups in the list, worst first, each with its state, SLI, budget left and burn rate, and a note when more groups have too few events to be tracked. A group with fewer than 100 eligible events in the window shows as "Too few events" and does not alert. The SLO page shows all groups together or one group, picked from a menu or a link (?group=, which group rows and alert notifications use); its numbers, charts and bad events follow the group. With all groups, the state is the worst group's. The definition panel names the group-by and how many groups there are, and the recent firings count when any group was firing. Co-Authored-By: Claude Opus 5.5 --- .changeset/slo-app.md | 16 ++ .../app/src/components/Slos/SloCharts.tsx | 4 + .../app/src/components/Slos/SloDetailPage.tsx | 55 ++++- .../src/components/Slos/SloDetailPanels.tsx | 26 ++- .../src/components/Slos/SloEventsDrawer.tsx | 18 +- .../src/components/Slos/SloGroupSelect.tsx | 57 +++++ .../app/src/components/Slos/SloNumbers.tsx | 11 +- .../src/components/Slos/SloRecentFirings.tsx | 15 +- .../app/src/components/Slos/SloStateBadge.tsx | 1 + packages/app/src/components/Slos/SloTable.tsx | 212 +++++++++++++----- packages/app/src/components/Slos/sloUtils.ts | 33 ++- .../src/components/Slos/useSloLiveStatus.ts | 46 ++-- 12 files changed, 393 insertions(+), 101 deletions(-) create mode 100644 .changeset/slo-app.md create mode 100644 packages/app/src/components/Slos/SloGroupSelect.tsx diff --git a/.changeset/slo-app.md b/.changeset/slo-app.md new file mode 100644 index 000000000..160266a4e --- /dev/null +++ b/.changeset/slo-app.md @@ -0,0 +1,16 @@ +--- +'@hyperdx/app': patch +--- + +feat: SLO pages behind NEXT_PUBLIC_ENABLE_SLOS + +Adds a list of SLOs, a builder with a preview of good, bad and excluded +events, and a detail page whose numbers and SLI, error budget and burn-rate +charts are computed when it opens, with its fast and slow burn alerts and +their firings over the last 7 days, and a flyout of bad events. A grouped SLO +expands into its groups in the list, and its detail page shows all groups +or one, picked from a menu or a link. The list filters by tag and source +and sorts by state, name, SLI, budget left or burn rate, and an SLO can be +duplicated without its alerts. Search gets an SLO button that starts the +builder from the current query, and SLO alerts show as such on the Alerts +page. diff --git a/packages/app/src/components/Slos/SloCharts.tsx b/packages/app/src/components/Slos/SloCharts.tsx index 83d41484d..6e9a40075 100644 --- a/packages/app/src/components/Slos/SloCharts.tsx +++ b/packages/app/src/components/Slos/SloCharts.tsx @@ -44,11 +44,14 @@ export function SloCharts({ slo, source, now, + group, onBucketSelect, }: { slo: SloApiResponse; source: TSource; now: Date; + /** One group of a grouped SLO. */ + group?: string; onBucketSelect: (start: Date, end: Date) => void; }) { const formatTime = useFormatTime(); @@ -56,6 +59,7 @@ export function SloCharts({ slo, source, now, + group, ); const bucketMs = convertGranularityToSeconds(granularity) * 1000; // The burn chart follows the rule's 1h condition, the one that pages first. diff --git a/packages/app/src/components/Slos/SloDetailPage.tsx b/packages/app/src/components/Slos/SloDetailPage.tsx index 770f185b7..c0cbdf871 100644 --- a/packages/app/src/components/Slos/SloDetailPage.tsx +++ b/packages/app/src/components/Slos/SloDetailPage.tsx @@ -3,7 +3,12 @@ import dynamic from 'next/dynamic'; import Head from 'next/head'; import Link from 'next/link'; import { useRouter } from 'next/router'; -import { parseAsInteger, parseAsStringEnum, useQueryStates } from 'nuqs'; +import { + parseAsInteger, + parseAsStringEnum, + useQueryState, + useQueryStates, +} from 'nuqs'; import type { SloApiResponse } from '@hyperdx/common-utils/dist/slo'; import type { TSource } from '@hyperdx/common-utils/dist/types'; import { @@ -32,6 +37,7 @@ import { type SloEventsRange, type SloEventsRequest, } from './SloEventsDrawer'; +import { SloGroupSelect } from './SloGroupSelect'; import { SloNumbers } from './SloNumbers'; import { SloRowMenu } from './SloRowMenu'; import { SloStateBadge } from './SloStateBadge'; @@ -42,13 +48,21 @@ import { useSloNow, } from './useSloLiveStatus'; +type SloGroupProps = { + /** The group of a grouped SLO the page shows; all groups when unset. */ + group?: string; + onGroupChange: (group: string | null) => void; +}; + function SloDetailView({ slo, source, now, live, liveError, -}: { + group, + onGroupChange, +}: SloGroupProps & { slo: SloApiResponse; source?: TSource; now?: Date; @@ -83,7 +97,16 @@ function SloDetailView({ setBadEvents({ bad: 'custom', from: start.getTime(), to: end.getTime() }), [setBadEvents], ); - const state = live?.state ?? getSloDisplayState(slo); + // A grouped SLO is as bad as its worst group, which its stored state + // knows and the live numbers of all groups together do not. + const state = + group != null + ? (live?.state ?? + slo.status?.groups?.find(g => g.value === group)?.state ?? + 'pending') + : slo.groupBy != null + ? getSloDisplayState(slo) + : (live?.state ?? getSloDisplayState(slo)); return (
@@ -104,6 +127,13 @@ function SloDetailView({ {slo.name} + {slo.groupBy != null && ( + + )} } actions={ @@ -130,6 +160,7 @@ function SloDetailView({ )} )} @@ -149,6 +181,7 @@ function SloDetailView({ setBadEvents({ bad: null, from: null, to: null })} @@ -161,12 +194,13 @@ function SloDetailView({ function SloDetailLive({ slo, source, -}: { + ...groupProps +}: SloGroupProps & { slo: SloApiResponse; source: TSource; }) { const now = useSloNow(); - const { live, error } = useSloLiveStatus(slo, source, now); + const { live, error } = useSloLiveStatus(slo, source, now, groupProps.group); return ( ); } @@ -187,6 +222,8 @@ function SloDetailPage() { const { data: source, isPending: isSourcePending } = useSource({ id: slo?.source, }); + // The group in view, from list rows and alert notifications too. + const [groupParam, setGroup] = useQueryState('group'); if (!enabled) return null; if (isPending || (slo != null && isSourcePending)) { @@ -207,11 +244,15 @@ function SloDetailPage() { ); } + const groupProps: SloGroupProps = { + group: slo.groupBy != null ? (groupParam ?? undefined) : undefined, + onGroupChange: value => void setGroup(value), + }; // A deleted source leaves the stored numbers, which say what went wrong. return source ? ( - + ) : ( - + ); } diff --git a/packages/app/src/components/Slos/SloDetailPanels.tsx b/packages/app/src/components/Slos/SloDetailPanels.tsx index f3e391ba1..65224c687 100644 --- a/packages/app/src/components/Slos/SloDetailPanels.tsx +++ b/packages/app/src/components/Slos/SloDetailPanels.tsx @@ -10,8 +10,9 @@ import { getSloAlertRuleLabel, getSloAlertTarget, SLO_BURN_CONDITIONS, + SLO_MAX_GROUPS, type SloApiResponse, - type SloState, + type SloGroupState, type SloStats, } from '@hyperdx/common-utils/dist/slo'; import { WebhookService } from '@hyperdx/common-utils/dist/types'; @@ -78,7 +79,7 @@ export function SloStatsGrid({ }: { slo: SloApiResponse; stats: SloStats; - state: SloState; + state: SloGroupState; }) { // The rule's conditions with their numbers, the 1h one first. const [hour, sixHours] = getSloBurnRule(slo.window).map((condition, i) => ({ @@ -173,7 +174,12 @@ export function SloAlertPanel({ slo }: { slo: SloApiResponse }) { ? `Notifies ${channels.join(', ')} when ${sentence}.` : `Turn it on to be notified when ${sentence}.`} - {target && status && } + {target && status && ( + + )} ); })} @@ -247,6 +253,20 @@ export function SloDefinitionPanel({ {slo.indicator.good} )} + {slo.groupBy != null && ( + + + Group by:{' '} + + {slo.groupBy} + {status?.groupCount != null && + `, ${formatCount(status.groupCount)} ${status.groupCount === 1 ? 'group' : 'groups'}` + + (status.groupCount > SLO_MAX_GROUPS + ? `; the ${SLO_MAX_GROUPS} with the most events are tracked` + : '')} + . Each group has its own SLI, error budget and alerts. + + )} Objective:{' '} diff --git a/packages/app/src/components/Slos/SloEventsDrawer.tsx b/packages/app/src/components/Slos/SloEventsDrawer.tsx index e3ccd486c..e9b019217 100644 --- a/packages/app/src/components/Slos/SloEventsDrawer.tsx +++ b/packages/app/src/components/Slos/SloEventsDrawer.tsx @@ -17,6 +17,7 @@ import { useZIndex, ZIndexContext } from '@/zIndex'; import { formatBurnWindow, formatCount, + formatSloGroup, formatSloWindow, getSourceDefaultSelect, } from './sloUtils'; @@ -37,12 +38,15 @@ export type SloEventsRequest = { export function SloEventsDrawer({ slo, source, + group, request, onRangeChange, onClose, }: { slo: SloApiResponse; source?: TSource; + /** One group of a grouped SLO. */ + group?: string; request: SloEventsRequest | null; onRangeChange: (range: 'burn' | 'window') => void; onClose: () => void; @@ -58,7 +62,7 @@ export function SloEventsDrawer({ const config = useMemo(() => { if (!source || !dateRange) return undefined; const defaultSelect = getSourceDefaultSelect(source); - const search = buildSloBadEventsSearch(slo, defaultSelect); + const search = buildSloBadEventsSearch(slo, defaultSelect, group); const sourceOrderBy = 'orderByExpression' in source ? source.orderByExpression?.trim() : ''; return { @@ -76,11 +80,14 @@ export function SloEventsDrawer({ }), dateRange, }; - }, [source, dateRange, slo]); + }, [source, dateRange, slo, group]); // The SLO's own count for the burn window, so a small difference from late // data is not a surprise. - const storedBurn = slo.status?.burn[0]; + const status = slo.status; + const storedBurn = ( + group != null ? status?.groups?.find(g => g.value === group) : status + )?.burn[0]; const sloBadCount = request?.range === 'burn' && storedBurn?.window === burn.window ? storedBurn.bad @@ -99,7 +106,10 @@ export function SloEventsDrawer({ > - + void; +}) { + const groups = slo.status?.groups ?? []; + const states = new Map(groups.map(g => [g.value, g.state])); + // A group from a link may be one the SLO does not track. + const values = groups.map(g => g.value); + if (group != null && !states.has(group)) values.unshift(group); + const data = [ + { value: ALL_GROUPS, label: 'All groups' }, + ...values.map(value => { + const state = states.get(value); + return { + value: `${GROUP_PREFIX}${value}`, + label: `${formatSloGroup(value)}${state ? ` (${sloStateLabel(state)})` : ''}`, + }; + }), + ]; + return ( +