Prometheus: Show only graph for range queries in Explore (#32489)

* Remove showing of table for range query

* Improve comment
This commit is contained in:
Ivana Huckova 2021-04-07 13:38:47 +02:00 committed by GitHub
parent 71e8a03c46
commit 61d3900b54
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 19 deletions

View File

@ -284,7 +284,6 @@ export class PrometheusDatasource extends DataSourceApi<PromQuery, PromOptions>
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<PromQuery, PromOptions>
query,
target,
responseListLength: queries.length,
mixedQueries,
exemplarTraceIdDestinations: this.exemplarTraceIdDestinations,
});
return {

View File

@ -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
*/