Fix formating of results from instant queries in Explore (#27767)

This commit is contained in:
Ivana Huckova
2020-09-25 14:34:33 +02:00
committed by GitHub
parent 204641a202
commit 336699c575
2 changed files with 8 additions and 2 deletions

View File

@@ -1868,7 +1868,7 @@ describe('prepareTargets', () => {
});
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 = {
refId: 'A',
expr: 'up',
@@ -1894,7 +1894,7 @@ describe('prepareTargets', () => {
start,
step: 1,
});
expect(activeTargets[0]).toEqual(target);
expect(activeTargets[0]).toEqual({ ...target, format: 'table' });
});
});
});

View File

@@ -237,6 +237,12 @@ export class PrometheusDatasource extends DataSourceApi<PromQuery, PromOptions>
this.createQuery(instantTarget, 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 {
queries.push(this.createQuery(target, options, start, end));
activeTargets.push(target);