From 30622923f6aacfbf5f97838a2a8751e9dbc81812 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Rica=20Pais=20da=20Silva?= Date: Tue, 17 Sep 2024 16:17:30 +0200 Subject: [PATCH] [Infra] Add observability feature id to host request (#192898) ## Summary Fixes the Hosts view for serverless by enabling the `observability` feature id for the `/api/metrics/infra/{assetType}` request. Closes #191078 ## How to test - Go to Infrastructure -> Hosts - Go to Alerts & Rules, Infrastructure Rules and create a new Inventory Rule, something like alert on cpu usage above certain %. - Allow the rule/alert to run - Go back to Infrastructure -> Hosts view - Hosts table should have a column with alert icons now visible for all hosts with alerts active on them. This should be tested against serverless + stateful versions of the Observability product. https://github.com/user-attachments/assets/8e0b36e0-30e6-4176-8190-592b3aaf2732 Co-authored-by: Elastic Machine --- .../server/routes/infra/lib/host/get_hosts_alerts_count.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/x-pack/plugins/observability_solution/infra/server/routes/infra/lib/host/get_hosts_alerts_count.ts b/x-pack/plugins/observability_solution/infra/server/routes/infra/lib/host/get_hosts_alerts_count.ts index 7da36dffda715..c3d8f0f674d55 100644 --- a/x-pack/plugins/observability_solution/infra/server/routes/infra/lib/host/get_hosts_alerts_count.ts +++ b/x-pack/plugins/observability_solution/infra/server/routes/infra/lib/host/get_hosts_alerts_count.ts @@ -6,6 +6,7 @@ */ import { termQuery, termsQuery } from '@kbn/observability-plugin/server'; +import { observabilityFeatureId } from '@kbn/observability-shared-plugin/common'; import { ALERT_RULE_PRODUCER, ALERT_STATUS, @@ -40,7 +41,7 @@ export async function getHostsAlertsCount({ query: { bool: { filter: [ - ...termQuery(ALERT_RULE_PRODUCER, INFRA_ALERT_FEATURE_ID), + ...termsQuery(ALERT_RULE_PRODUCER, INFRA_ALERT_FEATURE_ID, observabilityFeatureId), ...termQuery(ALERT_STATUS, ALERT_STATUS_ACTIVE), ...termsQuery(HOST_NAME_FIELD, ...hostNames), ...rangeQuery,