Alerting: Optimize Prometheus rules query params (#95833)

Load alert instances only when label filter is applied

Co-authored-by: Gilles De Mey <gilles.de.mey@gmail.com>
This commit is contained in:
Konrad Lalik 2024-11-05 14:35:53 +01:00 committed by GitHub
parent 34991f5b44
commit 91088d1f56
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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) {