mirror of
https://github.com/grafana/grafana.git
synced 2025-01-28 17:24:59 -06:00
Alerting: Use folder_uid instead of file for Grafana managed alert rules (#88497)
This commit is contained in:
parent
cd5f485df7
commit
33d4e59ffb
@ -1,3 +1,5 @@
|
||||
import { set } from 'lodash';
|
||||
|
||||
import { RelativeTimeRange } from '@grafana/data';
|
||||
import { Matcher } from 'app/plugins/datasource/alertmanager/types';
|
||||
import { RuleIdentifier, RuleNamespace, RulerDataSourceConfig } from 'app/types/unified-alerting';
|
||||
@ -17,7 +19,7 @@ import {
|
||||
|
||||
import { ExportFormats } from '../components/export/providers';
|
||||
import { Folder } from '../components/rule-editor/RuleFolderPicker';
|
||||
import { getDatasourceAPIUid, GRAFANA_RULES_SOURCE_NAME } from '../utils/datasource';
|
||||
import { getDatasourceAPIUid, GRAFANA_RULES_SOURCE_NAME, isGrafanaRulesSource } from '../utils/datasource';
|
||||
import { arrayKeyValuesToObject } from '../utils/labels';
|
||||
import { isCloudRuleIdentifier, isPrometheusRuleIdentifier } from '../utils/rules';
|
||||
|
||||
@ -174,13 +176,20 @@ export const alertRuleApi = alertingApi.injectEndpoints({
|
||||
>({
|
||||
query: ({ ruleSourceName, namespace, groupName, ruleName, dashboardUid, panelId }) => {
|
||||
const queryParams: Record<string, string | undefined> = {
|
||||
file: namespace,
|
||||
rule_group: groupName,
|
||||
rule_name: ruleName,
|
||||
dashboard_uid: dashboardUid, // Supported only by Grafana managed rules
|
||||
panel_id: panelId?.toString(), // Supported only by Grafana managed rules
|
||||
};
|
||||
|
||||
if (namespace) {
|
||||
if (isGrafanaRulesSource(ruleSourceName)) {
|
||||
set(queryParams, 'folder_uid', namespace);
|
||||
} else {
|
||||
set(queryParams, 'file', namespace);
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
url: `api/prometheus/${getDatasourceAPIUid(ruleSourceName)}/api/v1/rules`,
|
||||
params: queryParams,
|
||||
|
Loading…
Reference in New Issue
Block a user