Commit 336699c5 by Ivana Huckova Committed by GitHub

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

parent 204641a2
......@@ -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' });
});
});
});
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment