From ea0a6a1f7f97010bdc34bd9a80401e46a020f107 Mon Sep 17 00:00:00 2001 From: Sonia Aguilar <33540275+soniaAguilarPeiron@users.noreply.github.com> Date: Fri, 8 Nov 2024 16:07:43 +0100 Subject: [PATCH] Alerting: Force refetch prom rules when refreshing panel (#96120) Force refetch prom rules when refreshing panel --- .../dashboard-scene/scene/AlertStatesDataLayer.ts | 11 +++++++---- .../DashboardQueryRunner/UnifiedAlertStatesWorker.ts | 11 +++++++---- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/public/app/features/dashboard-scene/scene/AlertStatesDataLayer.ts b/public/app/features/dashboard-scene/scene/AlertStatesDataLayer.ts index 834b95b28ef..54f0a7264f8 100644 --- a/public/app/features/dashboard-scene/scene/AlertStatesDataLayer.ts +++ b/public/app/features/dashboard-scene/scene/AlertStatesDataLayer.ts @@ -73,10 +73,13 @@ export class AlertStatesDataLayer } const fetchData: () => Promise = async () => { const promRules = await dispatch( - alertRuleApi.endpoints.prometheusRuleNamespaces.initiate({ - ruleSourceName: GRAFANA_RULES_SOURCE_NAME, - dashboardUid: uid, - }) + alertRuleApi.endpoints.prometheusRuleNamespaces.initiate( + { + ruleSourceName: GRAFANA_RULES_SOURCE_NAME, + dashboardUid: uid, + }, + { forceRefetch: true } + ) ); if (promRules.error) { throw new Error(`Unexpected alert rules response.`); diff --git a/public/app/features/query/state/DashboardQueryRunner/UnifiedAlertStatesWorker.ts b/public/app/features/query/state/DashboardQueryRunner/UnifiedAlertStatesWorker.ts index bc750ffe8d8..8e352896e54 100644 --- a/public/app/features/query/state/DashboardQueryRunner/UnifiedAlertStatesWorker.ts +++ b/public/app/features/query/state/DashboardQueryRunner/UnifiedAlertStatesWorker.ts @@ -61,10 +61,13 @@ export class UnifiedAlertStatesWorker implements DashboardQueryRunnerWorker { const { dashboard } = options; const fetchData: () => Promise = async () => { const promRules = await dispatch( - alertRuleApi.endpoints.prometheusRuleNamespaces.initiate({ - ruleSourceName: GRAFANA_RULES_SOURCE_NAME, - dashboardUid: dashboard.uid, - }) + alertRuleApi.endpoints.prometheusRuleNamespaces.initiate( + { + ruleSourceName: GRAFANA_RULES_SOURCE_NAME, + dashboardUid: dashboard.uid, + }, + { forceRefetch: true } + ) ); return promRules.data; };