From 8d68bd6bb95c4c9c0ba734663ac9f881634b8ca3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Wed, 18 Oct 2017 13:27:55 +0200 Subject: [PATCH] fix: fixed prometheus step issue that caused browser crash, fixes #9575 --- .../plugins/datasource/prometheus/datasource.ts | 2 +- .../prometheus/specs/datasource_specs.ts | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/public/app/plugins/datasource/prometheus/datasource.ts b/public/app/plugins/datasource/prometheus/datasource.ts index e7b7cf36aa0..98776f37962 100644 --- a/public/app/plugins/datasource/prometheus/datasource.ts +++ b/public/app/plugins/datasource/prometheus/datasource.ts @@ -168,7 +168,7 @@ export class PrometheusDatasource { if (interval !== 0 && range / intervalFactor / interval > 11000) { interval = Math.ceil(range / intervalFactor / 11000); } - return Math.max(interval * intervalFactor, minInterval); + return Math.max(interval * intervalFactor, minInterval, 1); } performTimeSeriesQuery(query, start, end) { diff --git a/public/app/plugins/datasource/prometheus/specs/datasource_specs.ts b/public/app/plugins/datasource/prometheus/specs/datasource_specs.ts index 702ad8b5990..9d528c735de 100644 --- a/public/app/plugins/datasource/prometheus/specs/datasource_specs.ts +++ b/public/app/plugins/datasource/prometheus/specs/datasource_specs.ts @@ -294,6 +294,20 @@ describe('PrometheusDatasource', function() { ctx.ds.query(query); ctx.$httpBackend.verifyNoOutstandingExpectation(); }); + + it('step should never go below 1', function() { + var query = { + // 6 hour range + range: { from: moment(1508318768202), to: moment(1508318770118) }, + targets: [{expr: 'test'}], + interval: '100ms' + }; + var urlExpected = 'proxied/api/v1/query_range?query=test&start=1508318769&end=1508318771&step=1'; + ctx.$httpBackend.expect('GET', urlExpected).respond(response); + ctx.ds.query(query); + ctx.$httpBackend.verifyNoOutstandingExpectation(); + }); + it('should be auto interval when greater than min interval', function() { var query = { // 6 hour range