[v9.4.x] Alerting: Fix Graphite subqueries (#80969)

Alerting: Fix Graphite subqueries (#80744)

(cherry picked from commit 8a4bd85efd)
pull/87030/head
Gilles De Mey 1 year ago committed by GitHub
parent afba981303
commit 3f6f95f6fa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 6
      public/app/features/alerting/unified/components/rule-editor/QueryWrapper.tsx
  2. 6
      public/app/plugins/datasource/graphite/state/context.tsx
  3. 1
      public/app/plugins/datasource/graphite/types.ts

@ -145,6 +145,10 @@ export const QueryWrapper: FC<Props> = ({
}
}
// ⚠ 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 (
<div className={styles.wrapper}>
<QueryEditorRow<DataQuery>
@ -160,7 +164,7 @@ export const QueryWrapper: FC<Props> = ({
onRemoveQuery={onRemoveQuery}
onAddQuery={() => onDuplicateQuery(cloneDeep(query))}
onRunQuery={onRunQueries}
queries={queries}
queries={editorQueries}
renderHeaderExtras={() => <HeaderExtras query={query} index={index} error={error} />}
app={CoreApp.UnifiedAlerting}
visualization={

@ -76,7 +76,7 @@ export const GraphiteQueryEditorContext = ({
() => {
if (needsRefresh && state) {
setNeedsRefresh(false);
onChange({ ...query, target: state.target.target });
onChange({ ...query, target: state.target.target, targetFull: state.target.targetFull });
onRunQuery();
}
},
@ -92,8 +92,8 @@ export const GraphiteQueryEditorContext = ({
datasource: datasource,
range: range,
templateSrv: getTemplateSrv(),
// list of queries is passed only when the editor is in Dashboards. This is to allow interpolation
// of sub-queries which are stored in "targetFull" property used by alerting in the backend.
// 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. This is used by alerting in the backend.
queries: queries || [],
refresh: () => {
// 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;
textEditor?: boolean;
target?: string;
targetFull?: string;
tags?: string[];
fromAnnotations?: boolean;
}

Loading…
Cancel
Save