From b5736c3bf1f3456bd7085edc8b078f618f72ff71 Mon Sep 17 00:00:00 2001 From: Justin Kambic Date: Wed, 20 Nov 2024 13:45:37 -0500 Subject: [PATCH 1/6] Rename to --- .../slos/components/slos_overview/overview_item.tsx | 2 +- .../components/slos_overview/slo_overview_alerts.tsx | 8 ++++---- .../slos/components/slos_overview/slos_overview.tsx | 12 ++++++------ 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/x-pack/plugins/observability_solution/slo/public/pages/slos/components/slos_overview/overview_item.tsx b/x-pack/plugins/observability_solution/slo/public/pages/slos/components/slos_overview/overview_item.tsx index d26eea29f996c..f7953854b217d 100644 --- a/x-pack/plugins/observability_solution/slo/public/pages/slos/components/slos_overview/overview_item.tsx +++ b/x-pack/plugins/observability_solution/slo/public/pages/slos/components/slos_overview/overview_item.tsx @@ -9,7 +9,7 @@ import { EuiFlexItem, EuiStat, EuiToolTip } from '@elastic/eui'; import React from 'react'; import { useUrlSearchState } from '../../hooks/use_url_search_state'; -export function OverViewItem({ +export function OverviewItem({ title, description, titleColor, diff --git a/x-pack/plugins/observability_solution/slo/public/pages/slos/components/slos_overview/slo_overview_alerts.tsx b/x-pack/plugins/observability_solution/slo/public/pages/slos/components/slos_overview/slo_overview_alerts.tsx index 9fba8b59bef4a..1edfba0fffb4e 100644 --- a/x-pack/plugins/observability_solution/slo/public/pages/slos/components/slos_overview/slo_overview_alerts.tsx +++ b/x-pack/plugins/observability_solution/slo/public/pages/slos/components/slos_overview/slo_overview_alerts.tsx @@ -12,7 +12,7 @@ import { GetOverviewResponse } from '@kbn/slo-schema/src/rest_specs/routes/get_o import { rulesLocatorID, RulesParams } from '@kbn/observability-plugin/public'; import { useAlertsUrl } from '../../../../hooks/use_alerts_url'; import { useKibana } from '../../../../hooks/use_kibana'; -import { OverViewItem } from './overview_item'; +import { OverviewItem } from './overview_item'; export function SLOOverviewAlerts({ data, @@ -55,7 +55,7 @@ export function SLOOverviewAlerts({ - - - - - - - - Date: Wed, 20 Nov 2024 13:46:10 -0500 Subject: [PATCH 2/6] Add filter agg to healthy SLO agg to remove stale SLOs from doc_count. --- .../slo/server/services/get_slos_overview.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/x-pack/plugins/observability_solution/slo/server/services/get_slos_overview.ts b/x-pack/plugins/observability_solution/slo/server/services/get_slos_overview.ts index 2c1ff46f57ef5..d9a43b776908c 100644 --- a/x-pack/plugins/observability_solution/slo/server/services/get_slos_overview.ts +++ b/x-pack/plugins/observability_solution/slo/server/services/get_slos_overview.ts @@ -88,6 +88,17 @@ export class GetSLOsOverview { status: 'HEALTHY', }, }, + aggs: { + not_stale: { + filter: { + range: { + summaryUpdatedAt: { + gte: 'now-48h', + }, + }, + }, + }, + }, }, degrading: { filter: { @@ -133,7 +144,7 @@ export class GetSLOsOverview { return { violated: aggs?.violated.doc_count ?? 0, degrading: aggs?.degrading.doc_count ?? 0, - healthy: aggs?.healthy.doc_count ?? 0, + healthy: aggs?.healthy?.not_stale?.doc_count ?? 0, noData: aggs?.noData.doc_count ?? 0, stale: aggs?.stale.doc_count ?? 0, worst: { From e62cf5812f00990e93931f1dab08a249a2295cbc Mon Sep 17 00:00:00 2001 From: Justin Kambic Date: Fri, 22 Nov 2024 13:24:41 -0500 Subject: [PATCH 3/6] Apply not_stale filter to all sub-filters, except stale. --- .../slo/server/services/get_slos_overview.ts | 93 ++++++++++--------- 1 file changed, 50 insertions(+), 43 deletions(-) diff --git a/x-pack/plugins/observability_solution/slo/server/services/get_slos_overview.ts b/x-pack/plugins/observability_solution/slo/server/services/get_slos_overview.ts index d9a43b776908c..6af01a87b79e1 100644 --- a/x-pack/plugins/observability_solution/slo/server/services/get_slos_overview.ts +++ b/x-pack/plugins/observability_solution/slo/server/services/get_slos_overview.ts @@ -53,64 +53,71 @@ export class GetSLOsOverview { }, body: { aggs: { - worst: { - top_hits: { - sort: { - errorBudgetRemaining: { - order: 'asc', - }, - }, - _source: { - includes: ['sliValue', 'status', 'slo.id', 'slo.instanceId', 'slo.name'], - }, - size: 1, - }, - }, stale: { filter: { range: { summaryUpdatedAt: { - lt: `now-${settings.staleThresholdInHours}h`, + lt: 'now-48h', }, }, }, - }, - violated: { - filter: { - term: { - status: 'VIOLATED', + aggs: { + by_status: { + terms: { + field: 'status', + }, }, }, }, - healthy: { + not_stale: { filter: { - term: { - status: 'HEALTHY', + range: { + summaryUpdatedAt: { + gte: 'now-48h', + }, }, }, aggs: { - not_stale: { - filter: { - range: { - summaryUpdatedAt: { - gte: 'now-48h', + worst: { + top_hits: { + sort: { + errorBudgetRemaining: { + order: 'asc', }, }, + _source: { + includes: ['sliValue', 'status', 'slo.id', 'slo.instanceId', 'slo.name'], + }, + size: 1, }, }, - }, - }, - degrading: { - filter: { - term: { - status: 'DEGRADING', + violated: { + filter: { + term: { + status: 'VIOLATED', + }, + }, }, - }, - }, - noData: { - filter: { - term: { - status: 'NO_DATA', + healthy: { + filter: { + term: { + status: 'HEALTHY', + }, + }, + }, + degrading: { + filter: { + term: { + status: 'DEGRADING', + }, + }, + }, + noData: { + filter: { + term: { + status: 'NO_DATA', + }, + }, }, }, }, @@ -142,10 +149,10 @@ export class GetSLOsOverview { const aggs = response.aggregations; return { - violated: aggs?.violated.doc_count ?? 0, - degrading: aggs?.degrading.doc_count ?? 0, - healthy: aggs?.healthy?.not_stale?.doc_count ?? 0, - noData: aggs?.noData.doc_count ?? 0, + violated: aggs?.not_stale?.violated.doc_count ?? 0, + degrading: aggs?.not_stale?.degrading.doc_count ?? 0, + healthy: aggs?.not_stale?.healthy?.doc_count ?? 0, + noData: aggs?.not_stale?.noData.doc_count ?? 0, stale: aggs?.stale.doc_count ?? 0, worst: { value: 0, From a306667b81e1bfc4961c1d32c61e3fed08574a76 Mon Sep 17 00:00:00 2001 From: Justin Kambic Date: Mon, 25 Nov 2024 12:42:56 -0500 Subject: [PATCH 4/6] Remove unused filter. --- .../slo/server/services/get_slos_overview.ts | 20 ------------------- 1 file changed, 20 deletions(-) diff --git a/x-pack/plugins/observability_solution/slo/server/services/get_slos_overview.ts b/x-pack/plugins/observability_solution/slo/server/services/get_slos_overview.ts index 6af01a87b79e1..9f4abd0764263 100644 --- a/x-pack/plugins/observability_solution/slo/server/services/get_slos_overview.ts +++ b/x-pack/plugins/observability_solution/slo/server/services/get_slos_overview.ts @@ -61,13 +61,6 @@ export class GetSLOsOverview { }, }, }, - aggs: { - by_status: { - terms: { - field: 'status', - }, - }, - }, }, not_stale: { filter: { @@ -78,19 +71,6 @@ export class GetSLOsOverview { }, }, aggs: { - worst: { - top_hits: { - sort: { - errorBudgetRemaining: { - order: 'asc', - }, - }, - _source: { - includes: ['sliValue', 'status', 'slo.id', 'slo.instanceId', 'slo.name'], - }, - size: 1, - }, - }, violated: { filter: { term: { From fcd65bd3edbfe0455aac8793226470270a1424db Mon Sep 17 00:00:00 2001 From: Justin Kambic Date: Tue, 26 Nov 2024 09:07:13 -0500 Subject: [PATCH 5/6] Fix regression that ignores stale SLO settings. --- .../slo/server/services/get_slos_overview.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/observability_solution/slo/server/services/get_slos_overview.ts b/x-pack/plugins/observability_solution/slo/server/services/get_slos_overview.ts index 9f4abd0764263..fcc94072c7bb4 100644 --- a/x-pack/plugins/observability_solution/slo/server/services/get_slos_overview.ts +++ b/x-pack/plugins/observability_solution/slo/server/services/get_slos_overview.ts @@ -57,7 +57,7 @@ export class GetSLOsOverview { filter: { range: { summaryUpdatedAt: { - lt: 'now-48h', + lt: `now-${settings.staleThresholdInHours}h`, }, }, }, @@ -66,7 +66,7 @@ export class GetSLOsOverview { filter: { range: { summaryUpdatedAt: { - gte: 'now-48h', + gte: `now-${settings.staleThresholdInHours}h`, }, }, }, From 92033efbd663ae3b08df02b56d64696dbd776432 Mon Sep 17 00:00:00 2001 From: Justin Kambic Date: Tue, 26 Nov 2024 09:28:50 -0500 Subject: [PATCH 6/6] Remove unused type and key from API response. --- .../kbn-slo-schema/src/rest_specs/routes/get_overview.ts | 4 ---- .../slo/server/services/get_slos_overview.ts | 4 ---- 2 files changed, 8 deletions(-) diff --git a/x-pack/packages/kbn-slo-schema/src/rest_specs/routes/get_overview.ts b/x-pack/packages/kbn-slo-schema/src/rest_specs/routes/get_overview.ts index 9983bdee41e2d..679abc3d7f96a 100644 --- a/x-pack/packages/kbn-slo-schema/src/rest_specs/routes/get_overview.ts +++ b/x-pack/packages/kbn-slo-schema/src/rest_specs/routes/get_overview.ts @@ -18,10 +18,6 @@ const getOverviewResponseSchema = t.type({ degrading: t.number, stale: t.number, healthy: t.number, - worst: t.type({ - value: t.number, - id: t.string, - }), noData: t.number, burnRateRules: t.number, burnRateActiveAlerts: t.number, diff --git a/x-pack/plugins/observability_solution/slo/server/services/get_slos_overview.ts b/x-pack/plugins/observability_solution/slo/server/services/get_slos_overview.ts index fcc94072c7bb4..32660b68f4693 100644 --- a/x-pack/plugins/observability_solution/slo/server/services/get_slos_overview.ts +++ b/x-pack/plugins/observability_solution/slo/server/services/get_slos_overview.ts @@ -134,10 +134,6 @@ export class GetSLOsOverview { healthy: aggs?.not_stale?.healthy?.doc_count ?? 0, noData: aggs?.not_stale?.noData.doc_count ?? 0, stale: aggs?.stale.doc_count ?? 0, - worst: { - value: 0, - id: 'id', - }, burnRateRules: rules.total, burnRateActiveAlerts: alerts.activeAlertCount, burnRateRecoveredAlerts: alerts.recoveredAlertCount,