add a FE feature toggle to get a 'compact' response from the /rules endpoint
This commit is contained in:
@@ -422,6 +422,11 @@ export interface FeatureToggles {
|
||||
*/
|
||||
alertingQueryOptimization?: boolean;
|
||||
/**
|
||||
* Returns compact API responses for alert rules list, reducing payload size by omitting the query, notification settings, and metadata
|
||||
* @default false
|
||||
*/
|
||||
alertingCompactRulesResponse?: boolean;
|
||||
/**
|
||||
* Distributes alert rule evaluations more evenly over time, including spreading out rules within the same group. Disables sequential evaluation if enabled.
|
||||
*/
|
||||
jitterAlertRulesWithinGroups?: boolean;
|
||||
|
||||
@@ -686,6 +686,13 @@ var (
|
||||
Owner: grafanaAlertingSquad,
|
||||
Expression: "false",
|
||||
},
|
||||
{
|
||||
Name: "alertingCompactRulesResponse",
|
||||
Description: "Returns compact API responses for alert rules list, reducing payload size by omitting the query, notification settings, and metadata",
|
||||
Stage: FeatureStageExperimental,
|
||||
Owner: grafanaAlertingSquad,
|
||||
Expression: "false",
|
||||
},
|
||||
{
|
||||
Name: "jitterAlertRulesWithinGroups",
|
||||
Description: "Distributes alert rule evaluations more evenly over time, including spreading out rules within the same group. Disables sequential evaluation if enabled.",
|
||||
|
||||
Generated
+1
@@ -95,6 +95,7 @@ tableSharedCrosshair,experimental,@grafana/dataviz-squad,false,false,true
|
||||
kubernetesFeatureToggles,experimental,@grafana/grafana-operator-experience-squad,false,false,true
|
||||
cloudRBACRoles,preview,@grafana/identity-access-team,false,true,false
|
||||
alertingQueryOptimization,GA,@grafana/alerting-squad,false,false,false
|
||||
alertingCompactRulesResponse,experimental,@grafana/alerting-squad,false,false,false
|
||||
jitterAlertRulesWithinGroups,preview,@grafana/alerting-squad,false,true,false
|
||||
secretsManagementAppPlatform,experimental,@grafana/grafana-operator-experience-squad,false,false,false
|
||||
secretsManagementAppPlatformUI,experimental,@grafana/grafana-operator-experience-squad,false,false,false
|
||||
|
||||
|
Generated
+4
@@ -279,6 +279,10 @@ const (
|
||||
// Optimizes eligible queries in order to reduce load on datasources
|
||||
FlagAlertingQueryOptimization = "alertingQueryOptimization"
|
||||
|
||||
// FlagAlertingCompactRulesResponse
|
||||
// Returns compact API responses for alert rules list, reducing payload size by omitting the query, notification settings, and metadata
|
||||
FlagAlertingCompactRulesResponse = "alertingCompactRulesResponse"
|
||||
|
||||
// FlagJitterAlertRulesWithinGroups
|
||||
// Distributes alert rule evaluations more evenly over time, including spreading out rules within the same group. Disables sequential evaluation if enabled.
|
||||
FlagJitterAlertRulesWithinGroups = "jitterAlertRulesWithinGroups"
|
||||
|
||||
+16
@@ -195,6 +195,22 @@
|
||||
"codeowner": "@grafana/alerting-squad"
|
||||
}
|
||||
},
|
||||
{
|
||||
"metadata": {
|
||||
"name": "alertingCompactRulesResponse",
|
||||
"resourceVersion": "1765802340688",
|
||||
"creationTimestamp": "2025-12-15T12:24:06Z",
|
||||
"annotations": {
|
||||
"grafana.app/updatedTimestamp": "2025-12-15 12:39:00.688866597 +0000 UTC"
|
||||
}
|
||||
},
|
||||
"spec": {
|
||||
"description": "Returns compact API responses for alert rules list, reducing payload size by omitting the query, notification settings, and metadata",
|
||||
"stage": "experimental",
|
||||
"codeowner": "@grafana/alerting-squad",
|
||||
"expression": "false"
|
||||
}
|
||||
},
|
||||
{
|
||||
"metadata": {
|
||||
"name": "alertingDisableSendAlertsExternal",
|
||||
|
||||
@@ -47,6 +47,7 @@ export type GrafanaPromRulesOptions = Omit<PromRulesOptions, 'ruleSource' | 'nam
|
||||
title?: string;
|
||||
searchGroupName?: string;
|
||||
type?: 'alerting' | 'recording';
|
||||
compact?: boolean;
|
||||
};
|
||||
|
||||
export const prometheusApi = alertingApi.injectEndpoints({
|
||||
@@ -102,6 +103,7 @@ export const prometheusApi = alertingApi.injectEndpoints({
|
||||
datasources,
|
||||
searchGroupName,
|
||||
dashboardUid,
|
||||
compact,
|
||||
}) => ({
|
||||
url: `api/prometheus/grafana/api/v1/rules`,
|
||||
params: {
|
||||
@@ -120,6 +122,7 @@ export const prometheusApi = alertingApi.injectEndpoints({
|
||||
'search.rule_name': title,
|
||||
'search.rule_group': searchGroupName,
|
||||
dashboard_uid: dashboardUid,
|
||||
compact: compact,
|
||||
},
|
||||
}),
|
||||
providesTags: (_result, _error, { folderUid, groupName, ruleName }) => {
|
||||
|
||||
@@ -3,6 +3,7 @@ import { useMemo } from 'react';
|
||||
|
||||
import { GrafanaTheme2 } from '@grafana/data';
|
||||
import { t } from '@grafana/i18n';
|
||||
import { config } from '@grafana/runtime';
|
||||
import { Alert, Stack, useStyles2 } from '@grafana/ui';
|
||||
import { GrafanaRuleGroupIdentifier } from 'app/types/unified-alerting';
|
||||
|
||||
@@ -44,6 +45,7 @@ export function GrafanaGroupLoader({
|
||||
folderUid: groupIdentifier.namespace.uid,
|
||||
groupName: groupIdentifier.groupName,
|
||||
limitAlerts: 0,
|
||||
compact: config.featureToggles.alertingCompactRulesResponse,
|
||||
},
|
||||
{ pollingInterval: RULE_LIST_POLL_INTERVAL_MS }
|
||||
);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { useCallback } from 'react';
|
||||
import { MergeExclusive } from 'type-fest';
|
||||
|
||||
import { config } from '@grafana/runtime';
|
||||
import { DataSourceRulesSourceIdentifier, RuleHealth } from 'app/types/unified-alerting';
|
||||
import { PromAlertingRuleState, PromRuleGroupDTO } from 'app/types/unified-alerting-dto';
|
||||
|
||||
@@ -76,6 +77,7 @@ export function useGrafanaGroupsGenerator(hookOptions: UseGeneratorHookOptions =
|
||||
...fetchOptions,
|
||||
limitAlerts: hookOptions.limitAlerts,
|
||||
...fetchOptions.filter,
|
||||
compact: config.featureToggles.alertingCompactRulesResponse,
|
||||
}).unwrap();
|
||||
|
||||
if (hookOptions.populateCache) {
|
||||
|
||||
Reference in New Issue
Block a user