diff --git a/public/app/plugins/datasource/prometheus/datasource.test.ts b/public/app/plugins/datasource/prometheus/datasource.test.ts index 78cee404d3c..f03f244a2b1 100644 --- a/public/app/plugins/datasource/prometheus/datasource.test.ts +++ b/public/app/plugins/datasource/prometheus/datasource.test.ts @@ -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' }); }); }); }); diff --git a/public/app/plugins/datasource/prometheus/datasource.ts b/public/app/plugins/datasource/prometheus/datasource.ts index 4b2874de1cb..2d256642035 100644 --- a/public/app/plugins/datasource/prometheus/datasource.ts +++ b/public/app/plugins/datasource/prometheus/datasource.ts @@ -237,6 +237,12 @@ export class PrometheusDatasource extends DataSourceApi 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);