Commit 91ea8dcc by David Kaltschmidt

Explore: Fix JS error when switching between 2 prometheus datasources

- since the DataQuery rewrite, Explore starts by submitting its queries (Explore cant know if the queries are emtpty)
- The datasource intercepts an empty query and returns an empty list of time series, and also no table for the table query.
- The query hinter then received no series to analyse and was not guarding against this.
- This PR adds this guard.
parent efcbb92b
...@@ -437,7 +437,7 @@ export class PrometheusDatasource { ...@@ -437,7 +437,7 @@ export class PrometheusDatasource {
} }
getQueryHints(query: DataQuery, result: any[]) { getQueryHints(query: DataQuery, result: any[]) {
return getQueryHints(query.expr, result, this); return getQueryHints(query.expr || '', result, this);
} }
loadRules() { loadRules() {
......
...@@ -96,7 +96,7 @@ export function getQueryHints(query: string, series?: any[], datasource?: any): ...@@ -96,7 +96,7 @@ export function getQueryHints(query: string, series?: any[], datasource?: any):
} }
} }
if (series.length >= SUM_HINT_THRESHOLD_COUNT) { if (series && series.length >= SUM_HINT_THRESHOLD_COUNT) {
const simpleMetric = query.trim().match(/^\w+$/); const simpleMetric = query.trim().match(/^\w+$/);
if (simpleMetric) { if (simpleMetric) {
hints.push({ hints.push({
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment