[v10.2.x] Alerting: Fix Graphite subqueries (#80816)
Alerting: Fix Graphite subqueries (#80744)
(cherry picked from commit 8a4bd85efd)
Co-authored-by: Gilles De Mey <gilles.de.mey@gmail.com>
This commit is contained in:
co-authored by
Gilles De Mey
parent
6d67f0646f
commit
a7ae7cd935
@@ -140,6 +140,9 @@ export const QueryWrapper = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const showVizualisation = data.state !== LoadingState.NotStarted;
|
const showVizualisation = data.state !== LoadingState.NotStarted;
|
||||||
|
// ⚠️ the query editors want the entire array of queries passed as "DataQuery" NOT "AlertQuery"
|
||||||
|
// TypeScript isn't complaining here because the interfaces just happen to be compatible
|
||||||
|
const editorQueries = cloneDeep(queries.map((query) => query.model));
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack direction="column" gap={0.5}>
|
<Stack direction="column" gap={0.5}>
|
||||||
@@ -159,7 +162,7 @@ export const QueryWrapper = ({
|
|||||||
onRemoveQuery={onRemoveQuery}
|
onRemoveQuery={onRemoveQuery}
|
||||||
onAddQuery={() => onDuplicateQuery(cloneDeep(query))}
|
onAddQuery={() => onDuplicateQuery(cloneDeep(query))}
|
||||||
onRunQuery={onRunQueries}
|
onRunQuery={onRunQueries}
|
||||||
queries={queries}
|
queries={editorQueries}
|
||||||
renderHeaderExtras={() => <HeaderExtras query={query} index={index} error={error} />}
|
renderHeaderExtras={() => <HeaderExtras query={query} index={index} error={error} />}
|
||||||
app={CoreApp.UnifiedAlerting}
|
app={CoreApp.UnifiedAlerting}
|
||||||
hideDisableQuery={true}
|
hideDisableQuery={true}
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ export const GraphiteQueryEditorContext = ({
|
|||||||
() => {
|
() => {
|
||||||
if (needsRefresh && state) {
|
if (needsRefresh && state) {
|
||||||
setNeedsRefresh(false);
|
setNeedsRefresh(false);
|
||||||
onChange({ ...query, target: state.target.target });
|
onChange({ ...query, target: state.target.target, targetFull: state.target.targetFull });
|
||||||
onRunQuery();
|
onRunQuery();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -92,8 +92,8 @@ export const GraphiteQueryEditorContext = ({
|
|||||||
datasource: datasource,
|
datasource: datasource,
|
||||||
range: range,
|
range: range,
|
||||||
templateSrv: getTemplateSrv(),
|
templateSrv: getTemplateSrv(),
|
||||||
// list of queries is passed only when the editor is in Dashboards. This is to allow interpolation
|
// list of queries is passed only when the editor is in Dashboards or Alerting. This is to allow interpolation
|
||||||
// of sub-queries which are stored in "targetFull" property used by alerting in the backend.
|
// of sub-queries which are stored in "targetFull" property. This is used by alerting in the backend.
|
||||||
queries: queries || [],
|
queries: queries || [],
|
||||||
refresh: () => {
|
refresh: () => {
|
||||||
// do not run onChange/onRunQuery straight away to ensure the internal state gets updated first
|
// do not run onChange/onRunQuery straight away to ensure the internal state gets updated first
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ export interface GraphiteQuery extends DataQuery {
|
|||||||
queryType?: string;
|
queryType?: string;
|
||||||
textEditor?: boolean;
|
textEditor?: boolean;
|
||||||
target?: string;
|
target?: string;
|
||||||
|
targetFull?: string;
|
||||||
tags?: string[];
|
tags?: string[];
|
||||||
fromAnnotations?: boolean;
|
fromAnnotations?: boolean;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user