From a30a6042280247bb6b63a5fbfc27246669c27aa2 Mon Sep 17 00:00:00 2001 From: Jeff Klukas Date: Thu, 20 Nov 2014 09:32:19 -0600 Subject: [PATCH 01/12] Purge timspan variable from scripted templates. --- src/app/dashboards/scripted.js | 6 +++--- src/app/dashboards/scripted_async.js | 13 +++++++------ src/app/dashboards/scripted_templated.js | 14 ++++++++------ 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/app/dashboards/scripted.js b/src/app/dashboards/scripted.js index 8fca0248496..93e67aae5b9 100644 --- a/src/app/dashboards/scripted.js +++ b/src/app/dashboards/scripted.js @@ -17,7 +17,7 @@ var window, document, ARGS, $, jQuery, moment, kbn; // Setup some variables -var dashboard, timspan; +var dashboard; // All url parameters are available via the ARGS object var ARGS; @@ -30,11 +30,11 @@ dashboard = { // Set a title dashboard.title = 'Scripted dash'; -// set default time +// Set default time // time can be overriden in the url using from/to parameteres, but this is // handled automatically in grafana core during dashboard initialization dashboard.time = { - from: 'now-6h', + from: "now-6h", to: "now" }; diff --git a/src/app/dashboards/scripted_async.js b/src/app/dashboards/scripted_async.js index 0a50aa44d5e..71d77892c3b 100644 --- a/src/app/dashboards/scripted_async.js +++ b/src/app/dashboards/scripted_async.js @@ -22,10 +22,7 @@ var window, document, ARGS, $, jQuery, moment, kbn; return function(callback) { // Setup some variables - var dashboard, timspan; - - // Set a default timespan if one isn't specified - timspan = ARGS.from || 'now-1d'; + var dashboard; // Intialize a skeleton with nothing but a rows array and service object dashboard = { @@ -35,9 +32,13 @@ return function(callback) { // Set a title dashboard.title = 'Scripted dash'; + + // Set default time + // time can be overriden in the url using from/to parameteres, but this is + // handled automatically in grafana core during dashboard initialization dashboard.time = { - from: timspan, - to: "now" + from: "now-6h", + to: "now" }; var rows = 1; diff --git a/src/app/dashboards/scripted_templated.js b/src/app/dashboards/scripted_templated.js index 9ce145f4606..a0d3e081293 100644 --- a/src/app/dashboards/scripted_templated.js +++ b/src/app/dashboards/scripted_templated.js @@ -17,25 +17,27 @@ var window, document, ARGS, $, jQuery, moment, kbn; // Setup some variables -var dashboard, timspan; +var dashboard; // All url parameters are available via the ARGS object var ARGS; -// Set a default timespan if one isn't specified -timspan = ARGS.from || 'now-1d'; - // Intialize a skeleton with nothing but a rows array and service object dashboard = { rows : [], }; // Set a title -dashboard.title = 'Scripted dash'; +dashboard.title = 'Scripted and templated dash'; + +// Set default time +// time can be overriden in the url using from/to parameteres, but this is +// handled automatically in grafana core during dashboard initialization dashboard.time = { - from: timspan, + from: "now-6h", to: "now" }; + dashboard.templating = { enable: true, list: [ From 88c2f18b20fe3ad5f55beec767196bfc235748c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Fri, 21 Nov 2014 08:24:13 +0100 Subject: [PATCH 02/12] Graphite: fixed aliasSub graphite func definition --- src/app/services/graphite/gfunc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/services/graphite/gfunc.js b/src/app/services/graphite/gfunc.js index b875eec9719..9e3f35743af 100644 --- a/src/app/services/graphite/gfunc.js +++ b/src/app/services/graphite/gfunc.js @@ -194,7 +194,7 @@ function (_) { name: "aliasSub", category: categories.Special, params: [{ name: "search", type: 'string' }, { name: "replace", type: 'string' }], - defaultParams: ['', ''] + defaultParams: ['', '\\1'] }); addFuncDef({ From d198057eaf86cdee57ab91fabfcd6770ed20c6e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Fri, 21 Nov 2014 10:06:42 +0100 Subject: [PATCH 03/12] InfluxDB: fixed issue with using custom/absolute from time to now(), Fixes #1113 --- src/app/services/influxdb/influxdbDatasource.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/app/services/influxdb/influxdbDatasource.js b/src/app/services/influxdb/influxdbDatasource.js index 43e245bfc4c..c30f950e51b 100644 --- a/src/app/services/influxdb/influxdbDatasource.js +++ b/src/app/services/influxdb/influxdbDatasource.js @@ -372,8 +372,9 @@ function (angular, _, kbn, InfluxSeries, InfluxQueryBuilder) { function getTimeFilter(options) { var from = getInfluxTime(options.range.from); var until = getInfluxTime(options.range.to); + var fromIsAbsolute = from[from.length-1] === 's'; - if (until === 'now()') { + if (until === 'now()' && !fromIsAbsolute) { return 'time > now() - ' + from; } From e109f8d69cb04e260624e5561f3e8e16ef363614 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Fri, 21 Nov 2014 10:11:21 +0100 Subject: [PATCH 04/12] Graphite: added timeStack function definition, Closes #1118 --- src/app/services/graphite/gfunc.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/app/services/graphite/gfunc.js b/src/app/services/graphite/gfunc.js index 9e3f35743af..2d0d4675798 100644 --- a/src/app/services/graphite/gfunc.js +++ b/src/app/services/graphite/gfunc.js @@ -357,6 +357,17 @@ function (_) { defaultParams: ['1d'] }); + addFuncDef({ + name: 'timeStack', + category: categories.Transform, + params: [ + { name: "timeShiftUnit", type: "select", options: ['1h', '6h', '12h', '1d', '2d', '7d', '14d', '30d'] }, + { name: "timeShiftStart", type: "int" }, + { name: "timeShiftEnd", type: "int" } + ], + defaultParams: ['1d', 0, 7] + }); + addFuncDef({ name: 'summarize', category: categories.Transform, From e933369f565ac20b515ceb4883890ebe5c5a4062 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Fri, 21 Nov 2014 10:17:08 +0100 Subject: [PATCH 05/12] Singlestat: changed singlestat title to centered position, Closes #1117 --- src/app/components/panelmeta.js | 1 - src/app/directives/panelMenu.js | 5 ----- src/app/panels/singlestat/module.js | 1 - 3 files changed, 7 deletions(-) diff --git a/src/app/components/panelmeta.js b/src/app/components/panelmeta.js index 9b2b2d90104..fc26f1c3d0e 100644 --- a/src/app/components/panelmeta.js +++ b/src/app/components/panelmeta.js @@ -5,7 +5,6 @@ function () { function PanelMeta(options) { this.description = options.description; - this.titlePos = options.titlePos; this.fullscreen = options.fullscreen; this.menu = []; this.editorTabs = []; diff --git a/src/app/directives/panelMenu.js b/src/app/directives/panelMenu.js index 4b3970fba39..286d6e0bab7 100644 --- a/src/app/directives/panelMenu.js +++ b/src/app/directives/panelMenu.js @@ -147,11 +147,6 @@ function (angular, $, _) { dismiss(2200); }; - if ($scope.panelMeta.titlePos && $scope.panel.title) { - elem.css('text-align', 'left'); - $link.css('padding-left', '10px'); - } - elem.click(showMenu); $compile(elem.contents())($scope); } diff --git a/src/app/panels/singlestat/module.js b/src/app/panels/singlestat/module.js index 91dd019c4b7..1d9b0d838d3 100644 --- a/src/app/panels/singlestat/module.js +++ b/src/app/panels/singlestat/module.js @@ -18,7 +18,6 @@ function (angular, app, _, TimeSeries, kbn, PanelMeta) { $scope.panelMeta = new PanelMeta({ description: 'Singlestat panel', - titlePos: 'left', fullscreen: true, metricsEditor: true }); From 3cde783d1db0251ed075e68a11851374bfbbe89f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Fri, 21 Nov 2014 10:25:36 +0100 Subject: [PATCH 06/12] Graphite: Lexer fix, allow equal sign (=) in metric paths, Fixes #1114 --- CHANGELOG.md | 1 + src/app/services/graphite/lexer.js | 1 + src/test/specs/lexer-specs.js | 6 ++++++ 3 files changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f785ad5a0a6..863f71ec147 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - [Issue #1087](https://github.com/grafana/grafana/issues/1087). Panel: Fixed IE9 crash due to angular drag drop - [Issue #1093](https://github.com/grafana/grafana/issues/1093). SingleStatPanel: Fixed position for drilldown link tooltip when dashboard requires scrolling - [Issue #1095](https://github.com/grafana/grafana/issues/1095). DrilldownLink: template variables in params property was not interpolated +- [Issue #1114](https://github.com/grafana/grafana/issues/1114). Graphite: Lexer fix, allow equal sign (=) in metric paths # 1.9.0-rc1 (2014-11-17) diff --git a/src/app/services/graphite/lexer.js b/src/app/services/graphite/lexer.js index ee37e6a22ba..7306737d96e 100644 --- a/src/app/services/graphite/lexer.js +++ b/src/app/services/graphite/lexer.js @@ -129,6 +129,7 @@ define([ i === 63 || // ? i === 37 || // % i === 35 || // # + i === 61 || // = i >= 97 && i <= 122; // a-z } diff --git a/src/test/specs/lexer-specs.js b/src/test/specs/lexer-specs.js index 04531423802..65260d2e013 100644 --- a/src/test/specs/lexer-specs.js +++ b/src/test/specs/lexer-specs.js @@ -29,6 +29,12 @@ define([ expect(tokens[2].value).to.be('192-168-1-1'); }); + it('should tokenize metric expression with equal sign', function() { + var lexer = new Lexer('apps=test'); + var tokens = lexer.tokenize(); + expect(tokens[0].value).to.be('apps=test'); + }); + it('simple function2', function() { var lexer = new Lexer('offset(test.metric, -100)'); var tokens = lexer.tokenize(); From d1be4e2a90849828e0d0923e815642a9584757bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Fri, 21 Nov 2014 10:44:37 +0100 Subject: [PATCH 07/12] Light theme: tweaks to background color and table highlight rows, Closes #1119 --- src/css/less/variables.light.less | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/css/less/variables.light.less b/src/css/less/variables.light.less index 063d0148c37..0e78514cea0 100644 --- a/src/css/less/variables.light.less +++ b/src/css/less/variables.light.less @@ -14,7 +14,7 @@ @grayDark: lighten(#000, 20%); // #333 @gray: lighten(#000, 33.5%); // #555 @grayLight: lighten(#000, 60%); // #999 -@grayLighter: lighten(#000, 93.5%); // #eee +@grayLighter: lighten(#000, 97.5%); // #eee @white: #fff; @@ -53,14 +53,14 @@ // Scaffolding // ------------------------- -@bodyBackground: @grayLighter; +@bodyBackground: #EAEAEA; @textColor: #666; // Links // ------------------------- -@linkColor: @textColor; -@linkColorDisabled: lighten(@linkColor,35%); +@linkColor: darken(@textColor, 20%); +@linkColorDisabled: lighten(@linkColor,30%); @linkColorHover: @blue; From d0e057722bd9f875e183b4cac51d4f0b9de6a9b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Fri, 21 Nov 2014 17:48:49 +0100 Subject: [PATCH 08/12] Graphite: added more optional parameters to aliasByNode function definition, #1124 --- src/app/services/graphite/gfunc.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/app/services/graphite/gfunc.js b/src/app/services/graphite/gfunc.js index 2d0d4675798..af186633ea2 100644 --- a/src/app/services/graphite/gfunc.js +++ b/src/app/services/graphite/gfunc.js @@ -241,6 +241,8 @@ function (_) { params: [ { name: "node", type: "int", options: [0,1,2,3,4,5,6,7,8,9,10,12] }, { name: "node", type: "int", options: [0,-1,-2,-3,-4,-5,-6,-7], optional: true }, + { name: "node", type: "int", options: [0,-1,-2,-3,-4,-5,-6,-7], optional: true }, + { name: "node", type: "int", options: [0,-1,-2,-3,-4,-5,-6,-7], optional: true }, ], defaultParams: [3] }); From a1d652d57868c1543381b8d700574335b911d98d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Sat, 22 Nov 2014 15:26:23 +0100 Subject: [PATCH 09/12] SinglestatPanel: Added null point handling, and value to text mapping, Closes #1130, Fixes #1120, #951 --- CHANGELOG.md | 4 ++ src/app/panels/singlestat/editor.html | 43 ++++++++++++++++++++- src/app/panels/singlestat/module.js | 54 +++++++++++++++++++++++---- 3 files changed, 92 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 863f71ec147..ba6978289c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # 1.9.0 (unreleased) +**Enhancements** +- [Issue #1130](https://github.com/grafana/grafana/issues/1130). SinglestatPanel: Added null point handling, and value to text mapping + + **Fixes** - [Issue #1087](https://github.com/grafana/grafana/issues/1087). Panel: Fixed IE9 crash due to angular drag drop - [Issue #1093](https://github.com/grafana/grafana/issues/1093). SingleStatPanel: Fixed position for drilldown link tooltip when dashboard requires scrolling diff --git a/src/app/panels/singlestat/editor.html b/src/app/panels/singlestat/editor.html index 3265b3961d7..67df1405682 100644 --- a/src/app/panels/singlestat/editor.html +++ b/src/app/panels/singlestat/editor.html @@ -13,6 +13,10 @@ +
+ + +
@@ -38,6 +42,9 @@
+ + +
Coloring
@@ -54,9 +61,7 @@ invert order
- -
Spark lines
@@ -72,5 +77,39 @@
+
+
+
Value to text mapping
+
+ +
+
+
    +
  • + +
  • + +
  • + +
  • +
  • + +
  • +
  • + +
  • + +
  • + + + +
  • + +
+
+
+
+
+
diff --git a/src/app/panels/singlestat/module.js b/src/app/panels/singlestat/module.js index 1d9b0d838d3..3e248c7361a 100644 --- a/src/app/panels/singlestat/module.js +++ b/src/app/panels/singlestat/module.js @@ -34,9 +34,14 @@ function (angular, app, _, TimeSeries, kbn, PanelMeta) { format: 'none', prefix: '', postfix: '', + nullText: null, + valueMaps: [ + { value: 'null', op: '=', text: 'N/A' } + ], + nullPointMode: 'connected', valueName: 'avg', prefixFontSize: '50%', - valueFontSize: '100%', + valueFontSize: '80%', postfixFontSize: '50%', thresholds: '', colorBackground: false, @@ -98,7 +103,7 @@ function (angular, app, _, TimeSeries, kbn, PanelMeta) { alias: seriesData.target, }); - series.flotpairs = series.getFlotPairs('connected'); + series.flotpairs = series.getFlotPairs($scope.panel.nullPointMode); return series; }; @@ -169,15 +174,12 @@ function (angular, app, _, TimeSeries, kbn, PanelMeta) { if (!$scope.series || $scope.series.length === 0) { data.flotpairs = []; data.mainValue = Number.NaN; - data.mainValueFormated = 'NaN'; + data.mainValueFormated = $scope.getFormatedValue(null); } else { var series = $scope.series[0]; data.mainValue = series.stats[$scope.panel.valueName]; - var decimalInfo = $scope.getDecimalsForValue(data.mainValue); - var formatFunc = kbn.valueFormats[$scope.panel.format]; - - data.mainValueFormated = formatFunc(data.mainValue, decimalInfo.decimals, decimalInfo.scaledDecimals); + data.mainValueFormated = $scope.getFormatedValue(data.mainValue); data.flotpairs = series.flotpairs; } @@ -191,6 +193,44 @@ function (angular, app, _, TimeSeries, kbn, PanelMeta) { $scope.$emit('render'); }; + $scope.getFormatedValue = function(mainValue) { + + // first check value to text mappings + for(var i = 0; i < $scope.panel.valueMaps.length; i++) { + var map = $scope.panel.valueMaps[i]; + // special null case + if (map.value === 'null') { + if (mainValue === null || mainValue === void 0) { + return map.text; + } + continue; + } + // value/number to text mapping + var value = parseFloat(map.value); + if (value === mainValue) { + return map.text; + } + } + + if (mainValue === null || mainValue === void 0) { + return "no value"; + } + + var decimalInfo = $scope.getDecimalsForValue(mainValue); + var formatFunc = kbn.valueFormats[$scope.panel.format]; + return formatFunc(mainValue, decimalInfo.decimals, decimalInfo.scaledDecimals); + }; + + $scope.removeValueMap = function(map) { + var index = _.indexOf($scope.panel.valueMaps, map); + $scope.panel.valueMaps.splice(index, 1); + $scope.render(); + }; + + $scope.addValueMap = function() { + $scope.panel.valueMaps.push({value: '', op: '=', text: '' }); + }; + $scope.init(); }); }); From 8dfe85f23ebd126965e5e1c3c7d193ce8b1164c8 Mon Sep 17 00:00:00 2001 From: Johno Crawford Date: Tue, 25 Nov 2014 19:31:35 +0000 Subject: [PATCH 10/12] Support for negative thresholds. --- src/app/panels/singlestat/singleStatPanel.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/panels/singlestat/singleStatPanel.js b/src/app/panels/singlestat/singleStatPanel.js index 57df1a5eaae..6ac830d9e00 100644 --- a/src/app/panels/singlestat/singleStatPanel.js +++ b/src/app/panels/singlestat/singleStatPanel.js @@ -148,7 +148,7 @@ function (angular, app, _, $) { var body = getBigValueHtml(); - if (panel.colorBackground && data.mainValue) { + if (panel.colorBackground && !isNaN(data.mainValue)) { var color = getColorForValue(data.mainValue); if (color) { $panelContainer.css('background-color', color); From ed2ca5fced8da05542e0e77f6dd780e2f704529d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Wed, 26 Nov 2014 09:34:21 +0100 Subject: [PATCH 11/12] Graph: Fix to legend value Max and negative values, Fixes #1136 --- CHANGELOG.md | 1 + src/app/components/timeSeries.js | 4 ++-- src/test/specs/timeSeries-specs.js | 8 ++++++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f785ad5a0a6..00daadbdffa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - [Issue #1087](https://github.com/grafana/grafana/issues/1087). Panel: Fixed IE9 crash due to angular drag drop - [Issue #1093](https://github.com/grafana/grafana/issues/1093). SingleStatPanel: Fixed position for drilldown link tooltip when dashboard requires scrolling - [Issue #1095](https://github.com/grafana/grafana/issues/1095). DrilldownLink: template variables in params property was not interpolated +- [Issue #1136](https://github.com/grafana/grafana/issues/1136). Graph: Fix to legend value Max and negative values # 1.9.0-rc1 (2014-11-17) diff --git a/src/app/components/timeSeries.js b/src/app/components/timeSeries.js index f9329141640..fd7b9fe849a 100644 --- a/src/app/components/timeSeries.js +++ b/src/app/components/timeSeries.js @@ -64,7 +64,7 @@ function (_, kbn) { var result = []; this.stats.total = 0; - this.stats.max = Number.MIN_VALUE; + this.stats.max = -Number.MAX_VALUE; this.stats.min = Number.MAX_VALUE; this.stats.avg = null; this.stats.current = null; @@ -106,7 +106,7 @@ function (_, kbn) { this.stats.timeStep = this.datapoints[1][1] - this.datapoints[0][1]; } - if (this.stats.max === Number.MIN_VALUE) { this.stats.max = null; } + if (this.stats.max === -Number.MAX_VALUE) { this.stats.max = null; } if (this.stats.min === Number.MAX_VALUE) { this.stats.min = null; } if (result.length) { diff --git a/src/test/specs/timeSeries-specs.js b/src/test/specs/timeSeries-specs.js index e68ce16d54e..66d761ab193 100644 --- a/src/test/specs/timeSeries-specs.js +++ b/src/test/specs/timeSeries-specs.js @@ -35,6 +35,14 @@ define([ expect(series.stats.current).to.be(10); }); + it('max value should work for negative values', function() { + series = new TimeSeries({ + datapoints: [[-10,1], [-4, 2]] + }); + series.getFlotPairs('null', yAxisFormats); + expect(series.stats.max).to.be(-4); + }); + }); describe('series overrides', function() { From d7ef6daeb8133bd26c7f2cc57a9911770ecdd39b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Thu, 27 Nov 2014 10:41:20 +0100 Subject: [PATCH 12/12] SinglestatPanel: Fixed absolute drilldown link issue, Fixes #1150 --- CHANGELOG.md | 1 + src/app/panels/singlestat/singleStatPanel.js | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 44bc4d0be12..aab7128900a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ - [Issue #1095](https://github.com/grafana/grafana/issues/1095). DrilldownLink: template variables in params property was not interpolated - [Issue #1114](https://github.com/grafana/grafana/issues/1114). Graphite: Lexer fix, allow equal sign (=) in metric paths - [Issue #1136](https://github.com/grafana/grafana/issues/1136). Graph: Fix to legend value Max and negative values +- [Issue #1150](https://github.com/grafana/grafana/issues/1150). SinglestatPanel: Fixed absolute drilldown link issue # 1.9.0-rc1 (2014-11-17) diff --git a/src/app/panels/singlestat/singleStatPanel.js b/src/app/panels/singlestat/singleStatPanel.js index 6ac830d9e00..f3b0d946430 100644 --- a/src/app/panels/singlestat/singleStatPanel.js +++ b/src/app/panels/singlestat/singleStatPanel.js @@ -186,7 +186,13 @@ function (angular, app, _, $) { var linkInfo = linkSrv.getPanelLinkAnchorInfo(panel.links[0]); if (linkInfo.href[0] === '#') { linkInfo.href = linkInfo.href.substring(1); } - $timeout(function() { $location.url(linkInfo.href); }); + if (linkInfo.href.indexOf('http') === 0) { + window.location.href = linkInfo.href; + } else { + $timeout(function() { + $location.url(linkInfo.href); + }); + } drilldownTooltip.detach(); });