mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Alerting: Fix labels suggestions Grafana-managed rules (#73983)
This commit is contained in:
parent
43be03a2d8
commit
45a8ca3111
@ -312,6 +312,13 @@ export const QueryAndExpressionsStep = ({ editingExistingRule, onDataChange }: P
|
|||||||
prevCondition && setValue('condition', prevCondition);
|
prevCondition && setValue('condition', prevCondition);
|
||||||
} else {
|
} else {
|
||||||
setValue('type', RuleFormType.cloudAlerting);
|
setValue('type', RuleFormType.cloudAlerting);
|
||||||
|
// dataSourceName is used only by Mimir/Loki alerting and recording rules
|
||||||
|
// It should be empty for Grafana managed alert rules
|
||||||
|
const newDsName = getDataSourceSrv().getInstanceSettings(queries[0].datasourceUid)?.name;
|
||||||
|
if (newDsName) {
|
||||||
|
setValue('dataSourceName', newDsName);
|
||||||
|
}
|
||||||
|
|
||||||
updateExpressionAndDatasource(queries);
|
updateExpressionAndDatasource(queries);
|
||||||
|
|
||||||
const expressions = queries.filter((query) => query.datasourceUid === ExpressionDatasourceUID);
|
const expressions = queries.filter((query) => query.datasourceUid === ExpressionDatasourceUID);
|
||||||
@ -549,11 +556,9 @@ const useSetExpressionAndDataSource = () => {
|
|||||||
if (!dataSourceSettings) {
|
if (!dataSourceSettings) {
|
||||||
throw new Error('The Data source has not been defined.');
|
throw new Error('The Data source has not been defined.');
|
||||||
}
|
}
|
||||||
setValue('dataSourceName', dataSourceSettings.name);
|
|
||||||
|
|
||||||
if (isPromOrLokiQuery(query.model)) {
|
if (isPromOrLokiQuery(query.model)) {
|
||||||
const expression = query.model.expr;
|
const expression = query.model.expr;
|
||||||
|
|
||||||
setValue('expression', expression);
|
setValue('expression', expression);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user