From 6fae1df0713b35accb06ded7385ac7f1b13f8936 Mon Sep 17 00:00:00 2001 From: Dmytro Kozlov Date: Tue, 30 Jan 2024 09:57:30 +0100 Subject: [PATCH] fix query builder for alerting rules (#137) * properly process requests from Grafana's unified alerting tab * avoid cyclic calls to `/api/v1/eval` --- CHANGELOG.md | 3 ++- packages/lezer-metricsql/package.json | 2 +- src/components/PromQueryField.tsx | 4 ++-- src/querybuilder/components/PromQueryEditorSelector.tsx | 6 ++++-- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 481c2102..1f94c3b7 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,11 +3,12 @@ ## tip * BUGFIX: fix the default link to vmui. See [this issue](https://github.com/VictoriaMetrics/grafana-datasource/issues/132) +* BUGFIX: fix the parsing logic in `renderLegendFormat` to correctly replace legend label names. See [this issue](https://github.com/VictoriaMetrics/grafana-datasource/issues/133) +* BUGFIX: fix query editor which produce a lot of requests for alerting rule evaluation. See [this issue](https://github.com/VictoriaMetrics/grafana-datasource/issues/134) ## [v0.5.1](https://github.com/VictoriaMetrics/grafana-datasource/releases/tag/v0.5.1) * BUGFIX: fix query builder logic to correctly parse metric names with dots. See [this issue](https://github.com/VictoriaMetrics/grafana-datasource/issues/128) -* BUGFIX: fix the parsing logic in `renderLegendFormat` to correctly replace legend label names. See [this issue](https://github.com/VictoriaMetrics/grafana-datasource/issues/133) ## [v0.5.0](https://github.com/VictoriaMetrics/grafana-datasource/releases/tag/v0.5.0) diff --git a/packages/lezer-metricsql/package.json b/packages/lezer-metricsql/package.json index 734c1fff..3c93af80 100644 --- a/packages/lezer-metricsql/package.json +++ b/packages/lezer-metricsql/package.json @@ -1,6 +1,6 @@ { "name": "lezer-metricsql", - "version": "0.1.0", + "version": "0.1.1", "main": "index.cjs", "type": "module", "exports": { diff --git a/src/components/PromQueryField.tsx b/src/components/PromQueryField.tsx index 5954f5b2..254fd328 100755 --- a/src/components/PromQueryField.tsx +++ b/src/components/PromQueryField.tsx @@ -21,7 +21,7 @@ import React, { ReactNode } from 'react'; import { Plugin } from 'slate'; import { Editor } from 'slate-react'; -import { CoreApp, isDataFrame, QueryEditorProps, QueryHint, TimeRange, toLegacyResponseData } from '@grafana/data'; +import { isDataFrame, QueryEditorProps, QueryHint, TimeRange, toLegacyResponseData } from '@grafana/data'; import { BracesPlugin, Icon, @@ -263,7 +263,7 @@ class PromQueryField extends React.PureComponent ((props) => { const withTemplates = getArrayFromTemplate(templateByDashboard) datasource.languageProvider = new PrometheusLanguageProvider(datasource, { withTemplates }) datasource.languageProvider.start() - onRunQuery() - }, [onRunQuery, datasource, templateByDashboard]) + if (app !== CoreApp.UnifiedAlerting){ + onRunQuery(); + } + }, [onRunQuery, datasource, templateByDashboard, app]) return ( <>