From 91088d1f56d326c7e54e3262aaa6803f49d25bba Mon Sep 17 00:00:00 2001 From: Konrad Lalik Date: Tue, 5 Nov 2024 14:35:53 +0100 Subject: [PATCH] Alerting: Optimize Prometheus rules query params (#95833) Load alert instances only when label filter is applied Co-authored-by: Gilles De Mey --- .../app/features/alerting/unified/rule-list/RuleList.v1.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/public/app/features/alerting/unified/rule-list/RuleList.v1.tsx b/public/app/features/alerting/unified/rule-list/RuleList.v1.tsx index 2d565d3f259..88f3cf848b8 100644 --- a/public/app/features/alerting/unified/rule-list/RuleList.v1.tsx +++ b/public/app/features/alerting/unified/rule-list/RuleList.v1.tsx @@ -47,6 +47,8 @@ const RuleListV1 = () => { const [queryParams] = useQueryParams(); const { filterState, hasActiveFilters } = useRulesFilter(); + const hasActiveLabelsFilter = filterState.labels.length > 0; + const queryParamView = queryParams.view as keyof typeof VIEWS; const view = VIEWS[queryParamView] ? queryParamView : 'groups'; @@ -77,7 +79,7 @@ const RuleListV1 = () => { return noRules && state.dispatched; }); - const limitAlerts = hasActiveFilters ? undefined : LIMIT_ALERTS; + const limitAlerts = hasActiveLabelsFilter ? undefined : LIMIT_ALERTS; // Trigger data refresh only when the RULE_LIST_POLL_INTERVAL_MS elapsed since the previous load FINISHED const [_, fetchRules] = useAsyncFn(async () => { if (!loading) {