mirror of
https://github.com/grafana/grafana.git
synced 2024-11-30 20:54:22 -06:00
Prometheus: Show only graph for range queries in Explore (#32489)
* Remove showing of table for range query * Improve comment
This commit is contained in:
parent
71e8a03c46
commit
61d3900b54
@ -284,7 +284,6 @@ export class PrometheusDatasource extends DataSourceApi<PromQuery, PromOptions>
|
|||||||
|
|
||||||
private exploreQuery(queries: PromQueryRequest[], activeTargets: PromQuery[], end: number) {
|
private exploreQuery(queries: PromQueryRequest[], activeTargets: PromQuery[], end: number) {
|
||||||
let runningQueriesCount = queries.length;
|
let runningQueriesCount = queries.length;
|
||||||
const mixedQueries = activeTargets.some((t) => t.range) && activeTargets.some((t) => t.instant);
|
|
||||||
|
|
||||||
const subQueries = queries.map((query, index) => {
|
const subQueries = queries.map((query, index) => {
|
||||||
const target = activeTargets[index];
|
const target = activeTargets[index];
|
||||||
@ -299,7 +298,6 @@ export class PrometheusDatasource extends DataSourceApi<PromQuery, PromOptions>
|
|||||||
query,
|
query,
|
||||||
target,
|
target,
|
||||||
responseListLength: queries.length,
|
responseListLength: queries.length,
|
||||||
mixedQueries,
|
|
||||||
exemplarTraceIdDestinations: this.exemplarTraceIdDestinations,
|
exemplarTraceIdDestinations: this.exemplarTraceIdDestinations,
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
|
@ -45,7 +45,6 @@ export function transform(
|
|||||||
target: PromQuery;
|
target: PromQuery;
|
||||||
responseListLength: number;
|
responseListLength: number;
|
||||||
scopedVars?: ScopedVars;
|
scopedVars?: ScopedVars;
|
||||||
mixedQueries?: boolean;
|
|
||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
// Create options object from transformOptions
|
// Create options object from transformOptions
|
||||||
@ -61,14 +60,8 @@ export function transform(
|
|||||||
refId: transformOptions.target.refId,
|
refId: transformOptions.target.refId,
|
||||||
valueWithRefId: transformOptions.target.valueWithRefId,
|
valueWithRefId: transformOptions.target.valueWithRefId,
|
||||||
meta: {
|
meta: {
|
||||||
/**
|
// Fix for showing of Prometheus results in Explore table
|
||||||
* Fix for showing of Prometheus results in Explore table.
|
preferredVisualisationType: transformOptions.query.instant ? 'table' : 'graph',
|
||||||
* 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
|
|
||||||
),
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
const prometheusResult = response.data.data;
|
const prometheusResult = response.data.data;
|
||||||
@ -228,14 +221,6 @@ function sampleExemplars(events: TimeAndValue[], options: TransformOptions) {
|
|||||||
return sampledExemplars;
|
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
|
* Transforms matrix and vector result from Prometheus result to DataFrame
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user