[v11.2.x] Alerting: Force refetch prom rules when refreshing panel (#96124)

Alerting: Force refetch prom rules when refreshing panel (#96120)

Force refetch prom rules when refreshing panel

(cherry picked from commit ea0a6a1f7f)

Co-authored-by: Sonia Aguilar <33540275+soniaAguilarPeiron@users.noreply.github.com>
This commit is contained in:
grafana-delivery-bot[bot]
2024-11-08 16:36:22 +01:00
committed by GitHub
co-authored by Sonia Aguilar
parent d4b779e16c
commit 8e91bdea7a
2 changed files with 14 additions and 8 deletions
@@ -73,10 +73,13 @@ export class AlertStatesDataLayer
}
const fetchData: () => Promise<RuleNamespace[]> = 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.`);
@@ -61,10 +61,13 @@ export class UnifiedAlertStatesWorker implements DashboardQueryRunnerWorker {
const { dashboard } = options;
const fetchData: () => Promise<RuleNamespace[]> = 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;
};