From 61d3900b54ad7af1aa405e09c697b235ed732f8a Mon Sep 17 00:00:00 2001 From: Ivana Huckova <30407135+ivanahuckova@users.noreply.github.com> Date: Wed, 7 Apr 2021 13:38:47 +0200 Subject: [PATCH] Prometheus: Show only graph for range queries in Explore (#32489) * Remove showing of table for range query * Improve comment --- .../datasource/prometheus/datasource.ts | 2 -- .../prometheus/result_transformer.ts | 19 ++----------------- 2 files changed, 2 insertions(+), 19 deletions(-) diff --git a/public/app/plugins/datasource/prometheus/datasource.ts b/public/app/plugins/datasource/prometheus/datasource.ts index 5486588207d..98eddfc88e7 100644 --- a/public/app/plugins/datasource/prometheus/datasource.ts +++ b/public/app/plugins/datasource/prometheus/datasource.ts @@ -284,7 +284,6 @@ export class PrometheusDatasource extends DataSourceApi private exploreQuery(queries: PromQueryRequest[], activeTargets: PromQuery[], end: number) { let runningQueriesCount = queries.length; - const mixedQueries = activeTargets.some((t) => t.range) && activeTargets.some((t) => t.instant); const subQueries = queries.map((query, index) => { const target = activeTargets[index]; @@ -299,7 +298,6 @@ export class PrometheusDatasource extends DataSourceApi query, target, responseListLength: queries.length, - mixedQueries, exemplarTraceIdDestinations: this.exemplarTraceIdDestinations, }); return { diff --git a/public/app/plugins/datasource/prometheus/result_transformer.ts b/public/app/plugins/datasource/prometheus/result_transformer.ts index 4b67e09ce0c..2c7e625c76d 100644 --- a/public/app/plugins/datasource/prometheus/result_transformer.ts +++ b/public/app/plugins/datasource/prometheus/result_transformer.ts @@ -45,7 +45,6 @@ export function transform( target: PromQuery; responseListLength: number; scopedVars?: ScopedVars; - mixedQueries?: boolean; } ) { // Create options object from transformOptions @@ -61,14 +60,8 @@ export function transform( refId: transformOptions.target.refId, valueWithRefId: transformOptions.target.valueWithRefId, meta: { - /** - * Fix for showing of Prometheus results in Explore table. - * We want to show result of instant query always in table and result of range query based on target.runAll; - */ - preferredVisualisationType: getPreferredVisualisationType( - transformOptions.query.instant, - transformOptions.mixedQueries - ), + // Fix for showing of Prometheus results in Explore table + preferredVisualisationType: transformOptions.query.instant ? 'table' : 'graph', }, }; const prometheusResult = response.data.data; @@ -228,14 +221,6 @@ function sampleExemplars(events: TimeAndValue[], options: TransformOptions) { return sampledExemplars; } -function getPreferredVisualisationType(isInstantQuery?: boolean, mixedQueries?: boolean) { - if (isInstantQuery) { - return 'table'; - } - - return mixedQueries ? 'graph' : undefined; -} - /** * Transforms matrix and vector result from Prometheus result to DataFrame */