mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Fix formating of results from instant queries in Explore (#27767)
This commit is contained in:
@@ -1868,7 +1868,7 @@ describe('prepareTargets', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('when query type Instant is selected', () => {
|
describe('when query type Instant is selected', () => {
|
||||||
it('then it should just add targets', () => {
|
it('then it should target and modify its format to table', () => {
|
||||||
const target: PromQuery = {
|
const target: PromQuery = {
|
||||||
refId: 'A',
|
refId: 'A',
|
||||||
expr: 'up',
|
expr: 'up',
|
||||||
@@ -1894,7 +1894,7 @@ describe('prepareTargets', () => {
|
|||||||
start,
|
start,
|
||||||
step: 1,
|
step: 1,
|
||||||
});
|
});
|
||||||
expect(activeTargets[0]).toEqual(target);
|
expect(activeTargets[0]).toEqual({ ...target, format: 'table' });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -237,6 +237,12 @@ export class PrometheusDatasource extends DataSourceApi<PromQuery, PromOptions>
|
|||||||
this.createQuery(instantTarget, options, start, end),
|
this.createQuery(instantTarget, options, start, end),
|
||||||
this.createQuery(rangeTarget, options, start, end)
|
this.createQuery(rangeTarget, options, start, end)
|
||||||
);
|
);
|
||||||
|
} else if (target.instant && options.app === CoreApp.Explore) {
|
||||||
|
// If running only instant query in Explore, format as table
|
||||||
|
const instantTarget: any = cloneDeep(target);
|
||||||
|
instantTarget.format = 'table';
|
||||||
|
queries.push(this.createQuery(instantTarget, options, start, end));
|
||||||
|
activeTargets.push(instantTarget);
|
||||||
} else {
|
} else {
|
||||||
queries.push(this.createQuery(target, options, start, end));
|
queries.push(this.createQuery(target, options, start, end));
|
||||||
activeTargets.push(target);
|
activeTargets.push(target);
|
||||||
|
|||||||
Reference in New Issue
Block a user