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

Force refetch prom rules when refreshing panel
This commit is contained in:
Sonia Aguilar 2024-11-08 16:07:43 +01:00 committed by GitHub
parent b953190328
commit ea0a6a1f7f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 8 deletions

View File

@ -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.`);

View File

@ -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;
};