From a92103b2a9c06e3af30dea591ac769b995c78145 Mon Sep 17 00:00:00 2001 From: Justin Kambic Date: Tue, 26 Nov 2024 11:23:20 -0500 Subject: [PATCH] [SLO] Exclude stale slos from healthy count on overview (#201027) ## Summary Resolves #198911. The result is achieved by nesting a new filter agg inside the existing `HEALTHY` agg to remove any stale SLOs from the ultimate result. This required a modification of the parsing code on the ES response to include a new `not_stale` key. The original `success` total is preserved in the `doc_count` of that agg, but is no longer referenced. The filter for the `not_stale` agg I have added is the logical inverse of the filter we're using to determine stale SLOs: ```json { "range": { "summaryUpdatedAt": { "gte": "now-48h" } } } ``` _Reviewer note: I also changed the spelling of a UI component, should be a completely transparent change._ ## Example ### Before This is my local running on `main`: image ### After This is my local running on this PR branch: image ### Proof query works You can replicate these results by including a similar agg on a query against SLO data. I added a terms agg to the `stale` agg to determine how many SLOs I need to remove. The number of `HEALTHY` SLOs showing up in `stale` should match the difference between the total `doc_count` from `healthy` and the `doc_count` in the `not_stale` sub-aggregation. #### Query You can run this example aggs: ```json { "aggs": { "stale": { "filter": { "range": { "summaryUpdatedAt": { "lt": "now-48h" } } }, "aggs": { "by_status": { "terms": { "field": "status" } } } }, "healthy": { "filter": { "term": { "status": "HEALTHY" } }, "aggs": { "not_stale": { "filter": { "range": { "summaryUpdatedAt": { "gte": "now-48h" } } } } } } } } ``` #### Relevant output Here's a subset of my example query output. You can see that `stale.by_status.buckets[1]` contains a total of 2 docs, which is the difference between `healthy.doc_count` and `healthy.not_stale.doc_count`. ```json { "stale": { "doc_count": 7, "by_status": { "doc_count_error_upper_bound": 0, "sum_other_doc_count": 0, "buckets": [ { "key": "VIOLATED", "doc_count": 5 }, { "key": "HEALTHY", "doc_count": 2 } ] } }, "healthy": { "doc_count": 9, "not_stale": { "doc_count": 7 } } } ``` --- .../src/rest_specs/routes/get_overview.ts | 4 - .../slos_overview/overview_item.tsx | 2 +- .../slos_overview/slo_overview_alerts.tsx | 8 +- .../slos_overview/slos_overview.tsx | 12 +-- .../slo/server/services/get_slos_overview.ts | 76 +++++++++---------- 5 files changed, 46 insertions(+), 56 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/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({ - - - - - - - -