diff --git a/docs/sources/features/datasources/prometheus.md b/docs/sources/features/datasources/prometheus.md index 0ef05f8b57c..39793e0d453 100755 --- a/docs/sources/features/datasources/prometheus.md +++ b/docs/sources/features/datasources/prometheus.md @@ -111,7 +111,7 @@ Query: query_result(topk(5, sum(rate(http_requests_total[$__range])) by (instanc Regex: /"([^"]+)"/ ``` -Populate a variable with the instances having a certain state over the time range shown in the dashboard, using the more precise `$__range_s`: +Populate a variable with the instances having a certain state over the time range shown in the dashboard, using `$__range_s`: ``` Query: query_result(max_over_time([${__range_s}s]) != ) diff --git a/public/app/plugins/datasource/prometheus/datasource.test.ts b/public/app/plugins/datasource/prometheus/datasource.test.ts index 692a100fd52..7550e596f17 100644 --- a/public/app/plugins/datasource/prometheus/datasource.test.ts +++ b/public/app/plugins/datasource/prometheus/datasource.test.ts @@ -1456,7 +1456,7 @@ describe('PrometheusDatasource', () => { it('should use overridden ranges, not dashboard ranges', async () => { const expectedRangeSecond = 3600; - const expectedRangeString = '1h'; + const expectedRangeString = '3600s'; const query = { range: { from: time({}), diff --git a/public/app/plugins/datasource/prometheus/datasource.ts b/public/app/plugins/datasource/prometheus/datasource.ts index 8a1f3559414..996f50ac40e 100644 --- a/public/app/plugins/datasource/prometheus/datasource.ts +++ b/public/app/plugins/datasource/prometheus/datasource.ts @@ -519,11 +519,10 @@ export class PrometheusDatasource extends DataSourceApi getRangeScopedVars(range: TimeRange = getTimeSrv().timeRange()) { const msRange = range.to.diff(range.from); const sRange = Math.round(msRange / 1000); - const regularRange = kbn.secondsToHms(msRange / 1000); return { __range_ms: { text: msRange, value: msRange }, __range_s: { text: sRange, value: sRange }, - __range: { text: regularRange, value: regularRange }, + __range: { text: sRange + 's', value: sRange + 's' }, }; }