From 28ef972c9f877d5093de497e99a6fffe1f83cac1 Mon Sep 17 00:00:00 2001 From: ubhatnagar Date: Wed, 23 Sep 2015 22:13:38 +0530 Subject: [PATCH 01/10] Added duplicate feature for variable. --- public/app/features/templating/editorCtrl.js | 8 ++++++++ public/app/features/templating/partials/editor.html | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/public/app/features/templating/editorCtrl.js b/public/app/features/templating/editorCtrl.js index 74157ac3dd8..bd913e28fb5 100644 --- a/public/app/features/templating/editorCtrl.js +++ b/public/app/features/templating/editorCtrl.js @@ -96,6 +96,14 @@ function (angular, _) { } }; + $scope.duplicate = function(variable) { + $scope.current = angular.copy(variable); + $scope.variables.push($scope.current); + $scope.current = $scope.variables[$scope.variables.length - 1]; + $scope.current.name = 'copy_of_'+variable.name; + $scope.updateSubmenuVisibility(); + }; + $scope.update = function() { if ($scope.isValid()) { $scope.runQuery().then(function() { diff --git a/public/app/features/templating/partials/editor.html b/public/app/features/templating/partials/editor.html index 63ecd00adcf..43e2513e618 100644 --- a/public/app/features/templating/partials/editor.html +++ b/public/app/features/templating/partials/editor.html @@ -59,6 +59,11 @@ Edit + + + Duplicate + + From 9cdf0601eba06d63d6ea16698f257d8a8bb01432 Mon Sep 17 00:00:00 2001 From: ubhatnagar Date: Wed, 23 Sep 2015 22:20:38 +0530 Subject: [PATCH 02/10] Removed unnecessary statement. --- public/app/features/templating/editorCtrl.js | 1 - 1 file changed, 1 deletion(-) diff --git a/public/app/features/templating/editorCtrl.js b/public/app/features/templating/editorCtrl.js index bd913e28fb5..09dc300934e 100644 --- a/public/app/features/templating/editorCtrl.js +++ b/public/app/features/templating/editorCtrl.js @@ -99,7 +99,6 @@ function (angular, _) { $scope.duplicate = function(variable) { $scope.current = angular.copy(variable); $scope.variables.push($scope.current); - $scope.current = $scope.variables[$scope.variables.length - 1]; $scope.current.name = 'copy_of_'+variable.name; $scope.updateSubmenuVisibility(); }; From 2a600b25e76ec28d51c67df9204ba5229a29429c Mon Sep 17 00:00:00 2001 From: Alec Henninger Date: Mon, 16 Nov 2015 08:43:41 -0500 Subject: [PATCH 03/10] Ignore nulls unless 'null as zero' for series.stats.avg --- public/app/core/time_series.ts | 4 +++- public/test/core/time_series_specs.js | 11 +++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/public/app/core/time_series.ts b/public/app/core/time_series.ts index 30086be622a..8c8f1ee8eb6 100644 --- a/public/app/core/time_series.ts +++ b/public/app/core/time_series.ts @@ -98,6 +98,7 @@ class TimeSeries { var nullAsZero = fillStyle === 'null as zero'; var currentTime; var currentValue; + var nonNulls = 0; for (var i = 0; i < this.datapoints.length; i++) { currentValue = this.datapoints[i][0]; @@ -114,6 +115,7 @@ class TimeSeries { if (_.isNumber(currentValue)) { this.stats.total += currentValue; this.allIsNull = false; + nonNulls++; } if (currentValue > this.stats.max) { @@ -136,7 +138,7 @@ class TimeSeries { if (this.stats.min === Number.MAX_VALUE) { this.stats.min = null; } if (result.length) { - this.stats.avg = (this.stats.total / result.length); + this.stats.avg = (this.stats.total / nonNulls); this.stats.current = result[result.length-1][1]; if (this.stats.current === null && result.length > 1) { this.stats.current = result[result.length-2][1]; diff --git a/public/test/core/time_series_specs.js b/public/test/core/time_series_specs.js index 22d85775a05..5d6950ad2b6 100644 --- a/public/test/core/time_series_specs.js +++ b/public/test/core/time_series_specs.js @@ -43,6 +43,17 @@ define([ expect(series.stats.max).to.be(-4); }); + it('average value should ignore nulls', function() { + series = new TimeSeries(testData); + series.getFlotPairs('null', yAxisFormats); + expect(series.stats.avg).to.be(6.333333333333333); + }); + + it('with null as zero style, average value should treat nulls as 0', function() { + series = new TimeSeries(testData); + series.getFlotPairs('null as zero', yAxisFormats); + expect(series.stats.avg).to.be(4.75); + }); }); describe('series overrides', function() { From b0c01369c57c5fd298bbd8185b04c24d4137bc1a Mon Sep 17 00:00:00 2001 From: Christoph Krybus Date: Thu, 19 Nov 2015 13:44:46 +0100 Subject: [PATCH 04/10] Fix recommended graphite version for better performance There is no 0.9.13 graphite release, only 0.9.14. --- docs/sources/installation/performance.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/sources/installation/performance.md b/docs/sources/installation/performance.md index 51ab747bcd2..f09686687ca 100644 --- a/docs/sources/installation/performance.md +++ b/docs/sources/installation/performance.md @@ -8,7 +8,7 @@ page_keywords: grafana, performance, documentation ## Graphite -Graphite 0.9.13 adds a much needed feature to the JSON rendering API +Graphite 0.9.14 adds a much needed feature to the JSON rendering API that is very important for Grafana. If you are experiencing slow load & rendering times for large time ranges then it is most likely caused by running Graphite 0.9.12 or lower. @@ -17,6 +17,6 @@ The latest version of Graphite adds a `maxDataPoints` parameter to the JSON render API. Without this feature Graphite can return hundreds of thousands of data points per graph, which can hang your browser. Be sure to upgrade to -[0.9.13](http://graphite.readthedocs.org/en/latest/releases/0_9_13.html). +[0.9.14](http://graphite.readthedocs.org/en/latest/releases/0_9_14.html). From a6e8d61e8ef1791582c1252bbabc13a3b719fa4f Mon Sep 17 00:00:00 2001 From: Mauro Stettler Date: Fri, 20 Nov 2015 02:11:48 +0900 Subject: [PATCH 05/10] specify date format in elastic search query --- public/app/plugins/datasource/elasticsearch/query_builder.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/public/app/plugins/datasource/elasticsearch/query_builder.js b/public/app/plugins/datasource/elasticsearch/query_builder.js index 129c52d3f02..34156397ed0 100644 --- a/public/app/plugins/datasource/elasticsearch/query_builder.js +++ b/public/app/plugins/datasource/elasticsearch/query_builder.js @@ -10,7 +10,7 @@ function (angular) { ElasticQueryBuilder.prototype.getRangeFilter = function() { var filter = {}; - filter[this.timeField] = {"gte": "$timeFrom", "lte": "$timeTo"}; + filter[this.timeField] = {"gte": "$timeFrom", "lte": "$timeTo", "format": "epoch_millis"}; return filter; }; @@ -127,6 +127,7 @@ function (angular) { "interval": this.getInterval(aggDef), "field": this.timeField, "min_doc_count": 0, + "format": "epoch_millis", "extended_bounds": { "min": "$timeFrom", "max": "$timeTo" } }; break; From 4254aa5f5a27271f88b74f6b86b27813c2e09015 Mon Sep 17 00:00:00 2001 From: Mitsuhiro Tanda Date: Fri, 20 Nov 2015 13:06:25 +0900 Subject: [PATCH 06/10] (cloudwatch) fix null point mode --- public/app/plugins/datasource/cloudwatch/datasource.js | 2 +- .../app/plugins/datasource/cloudwatch/specs/datasource_specs.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/public/app/plugins/datasource/cloudwatch/datasource.js b/public/app/plugins/datasource/cloudwatch/datasource.js index 91b00f8f84a..79f4a6a00c7 100644 --- a/public/app/plugins/datasource/cloudwatch/datasource.js +++ b/public/app/plugins/datasource/cloudwatch/datasource.js @@ -263,7 +263,7 @@ function (angular, _) { }) .each(function(dp) { var timestamp = new Date(dp.Timestamp).getTime(); - if (lastTimestamp && (timestamp - lastTimestamp) > periodMs * 2) { + if (lastTimestamp && (timestamp - lastTimestamp) > periodMs) { dps.push([null, lastTimestamp + periodMs]); } lastTimestamp = timestamp; diff --git a/public/app/plugins/datasource/cloudwatch/specs/datasource_specs.ts b/public/app/plugins/datasource/cloudwatch/specs/datasource_specs.ts index 95526e38489..39d48e273b3 100644 --- a/public/app/plugins/datasource/cloudwatch/specs/datasource_specs.ts +++ b/public/app/plugins/datasource/cloudwatch/specs/datasource_specs.ts @@ -55,7 +55,7 @@ describe('CloudWatchDatasource', function() { }, { Average: 5, - Timestamp: 'Wed Dec 31 1969 16:20:00 GMT-0800 (PST)' + Timestamp: 'Wed Dec 31 1969 16:15:00 GMT-0800 (PST)' } ], Label: 'CPUUtilization' From 15dc30edf67dff8d6f83516988eb7b7d80feba04 Mon Sep 17 00:00:00 2001 From: Mitsuhiro Tanda Date: Fri, 13 Nov 2015 21:45:15 +0900 Subject: [PATCH 07/10] if there isn't enough datapoint, add null data point --- .../datasource/prometheus/datasource.js | 37 ++++++++++++------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/public/app/plugins/datasource/prometheus/datasource.js b/public/app/plugins/datasource/prometheus/datasource.js index c86fa2806d3..7e45c10246c 100644 --- a/public/app/plugins/datasource/prometheus/datasource.js +++ b/public/app/plugins/datasource/prometheus/datasource.js @@ -48,6 +48,7 @@ function (angular, _, moment, dateMath) { var end = getPrometheusTime(options.range.to, true); var queries = []; + options = _.clone(options); _.each(options.targets, _.bind(function(target) { if (!target.expr || target.hide) { return; @@ -58,7 +59,13 @@ function (angular, _, moment, dateMath) { var interval = target.interval || options.interval; var intervalFactor = target.intervalFactor || 1; - query.step = this.calculateInterval(interval, intervalFactor); + target.step = query.step = this.calculateInterval(interval, intervalFactor); + var range = Math.ceil(end - start); + // Prometheus drop query if range/step > 11000 + // calibrate step if it is too big + if (query.step !== 0 && range / query.step > 11000) { + target.step = query.step = Math.ceil(range / 11000); + } queries.push(query); }, this)); @@ -96,17 +103,7 @@ function (angular, _, moment, dateMath) { }; PrometheusDatasource.prototype.performTimeSeriesQuery = function(query, start, end) { - var url = '/api/v1/query_range?query=' + encodeURIComponent(query.expr) + '&start=' + start + '&end=' + end; - - var step = query.step; - var range = Math.ceil(end - start); - // Prometheus drop query if range/step > 11000 - // calibrate step if it is too big - if (step !== 0 && range / step > 11000) { - step = Math.ceil(range / 11000); - } - url += '&step=' + step; - + var url = '/api/v1/query_range?query=' + encodeURIComponent(query.expr) + '&start=' + start + '&end=' + end + '&step=' + query.step; return this._request('GET', url); }; @@ -221,8 +218,20 @@ function (angular, _, moment, dateMath) { metricLabel = createMetricLabel(md.metric, options); - dps = _.map(md.values, function(value) { - return [parseFloat(value[1]), value[0] * 1000]; + var stepMs = parseInt(options.step.slice(0, -1)) * 1000; + var lastTimestamp = null; + _.each(md.values, function(value) { + var dp_value = parseFloat(value[1]); + if (_.isNaN(dp_value)) { + dp_value = null; + } + + var timestamp = value[0] * 1000; + if (lastTimestamp && (timestamp - lastTimestamp) > stepMs) { + dps.push([null, lastTimestamp + stepMs]); + } + lastTimestamp = timestamp; + dps.push([dp_value, timestamp]); }); return { target: metricLabel, datapoints: dps }; From c4048f8f226ca61a82dbdeeaa82ca245637dbbd6 Mon Sep 17 00:00:00 2001 From: John McFarlane Date: Thu, 19 Nov 2015 16:33:08 -0800 Subject: [PATCH 08/10] [prometheus] Fix step calibration The step interval is (correctly) being converted to seconds, but the unit of measure suffixed onto the end is preventing the subsequent step calibration. Because the query upstream defaults to seconds as the unit of measure, the suffix can simply be removed and everything works as intended. patchset 01: Also fix the spec. --- public/app/plugins/datasource/prometheus/datasource.js | 2 +- .../app/plugins/datasource/prometheus/specs/datasource_specs.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/public/app/plugins/datasource/prometheus/datasource.js b/public/app/plugins/datasource/prometheus/datasource.js index c86fa2806d3..1b083d16956 100644 --- a/public/app/plugins/datasource/prometheus/datasource.js +++ b/public/app/plugins/datasource/prometheus/datasource.js @@ -212,7 +212,7 @@ function (angular, _, moment, dateMath) { sec = 1; } - return Math.ceil(sec * intervalFactor) + 's'; + return Math.ceil(sec * intervalFactor); }; function transformMetricData(md, options) { diff --git a/public/app/plugins/datasource/prometheus/specs/datasource_specs.ts b/public/app/plugins/datasource/prometheus/specs/datasource_specs.ts index 2ac4992edef..58034d09cac 100644 --- a/public/app/plugins/datasource/prometheus/specs/datasource_specs.ts +++ b/public/app/plugins/datasource/prometheus/specs/datasource_specs.ts @@ -19,7 +19,7 @@ describe('PrometheusDatasource', function() { var results; var urlExpected = 'proxied/api/v1/query_range?query=' + encodeURIComponent('test{job="testjob"}') + - '&start=1443438675&end=1443460275&step=60s'; + '&start=1443438675&end=1443460275&step=60'; var query = { range: { from: moment(1443438674760), to: moment(1443460274760) }, targets: [{ expr: 'test{job="testjob"}' }], From a1fcd3c5b6247db96e10e3d138aea794ba945eb2 Mon Sep 17 00:00:00 2001 From: Mitsuhiro Tanda Date: Fri, 20 Nov 2015 15:33:52 +0900 Subject: [PATCH 09/10] import fix step calibration --- public/app/plugins/datasource/prometheus/datasource.js | 4 ++-- .../plugins/datasource/prometheus/specs/datasource_specs.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/public/app/plugins/datasource/prometheus/datasource.js b/public/app/plugins/datasource/prometheus/datasource.js index 7e45c10246c..2c9279cee96 100644 --- a/public/app/plugins/datasource/prometheus/datasource.js +++ b/public/app/plugins/datasource/prometheus/datasource.js @@ -209,7 +209,7 @@ function (angular, _, moment, dateMath) { sec = 1; } - return Math.ceil(sec * intervalFactor) + 's'; + return Math.ceil(sec * intervalFactor); }; function transformMetricData(md, options) { @@ -218,7 +218,7 @@ function (angular, _, moment, dateMath) { metricLabel = createMetricLabel(md.metric, options); - var stepMs = parseInt(options.step.slice(0, -1)) * 1000; + var stepMs = parseInt(options.step) * 1000; var lastTimestamp = null; _.each(md.values, function(value) { var dp_value = parseFloat(value[1]); diff --git a/public/app/plugins/datasource/prometheus/specs/datasource_specs.ts b/public/app/plugins/datasource/prometheus/specs/datasource_specs.ts index 2ac4992edef..58034d09cac 100644 --- a/public/app/plugins/datasource/prometheus/specs/datasource_specs.ts +++ b/public/app/plugins/datasource/prometheus/specs/datasource_specs.ts @@ -19,7 +19,7 @@ describe('PrometheusDatasource', function() { var results; var urlExpected = 'proxied/api/v1/query_range?query=' + encodeURIComponent('test{job="testjob"}') + - '&start=1443438675&end=1443460275&step=60s'; + '&start=1443438675&end=1443460275&step=60'; var query = { range: { from: moment(1443438674760), to: moment(1443460274760) }, targets: [{ expr: 'test{job="testjob"}' }], From 57a31828f872ae937db3ff46bf0a6121489309be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Fri, 20 Nov 2015 08:18:03 +0100 Subject: [PATCH 10/10] fix(templating): very minor markup/css change --- public/app/features/templating/partials/editor.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/app/features/templating/partials/editor.html b/public/app/features/templating/partials/editor.html index 469bbb547cf..484495b3951 100644 --- a/public/app/features/templating/partials/editor.html +++ b/public/app/features/templating/partials/editor.html @@ -39,7 +39,7 @@
-
+
No template variables defined