From 5d6998cf0b566f2d79d996b60f1660e6d856c8cc Mon Sep 17 00:00:00 2001 From: felixbarnsteiner Date: Fri, 9 May 2014 11:18:18 +0200 Subject: [PATCH 1/6] url decode metric names #327 --- src/app/directives/grafanaGraph.js | 2 +- src/app/filters/all.js | 6 ++++++ src/app/panels/filtering/module.html | 2 +- src/app/panels/graphite/legend.html | 2 +- src/app/partials/graphite/editor.html | 2 +- 5 files changed, 10 insertions(+), 4 deletions(-) mode change 100644 => 100755 src/app/directives/grafanaGraph.js mode change 100644 => 100755 src/app/filters/all.js mode change 100644 => 100755 src/app/panels/filtering/module.html mode change 100644 => 100755 src/app/panels/graphite/legend.html mode change 100644 => 100755 src/app/partials/graphite/editor.html diff --git a/src/app/directives/grafanaGraph.js b/src/app/directives/grafanaGraph.js old mode 100644 new mode 100755 index d5a44598ad0..7a47983bd60 --- a/src/app/directives/grafanaGraph.js +++ b/src/app/directives/grafanaGraph.js @@ -313,7 +313,7 @@ function (angular, $, kbn, moment, _) { if (seriesInfo.alias) { group = '' + '' + ' ' + - (seriesInfo.alias || seriesInfo.query)+ + (decodeURIComponent(seriesInfo.alias) || seriesInfo.query)+ '
'; } else { group = kbn.query_color_dot(item.series.color, 15) + ' '; diff --git a/src/app/filters/all.js b/src/app/filters/all.js old mode 100644 new mode 100755 index e4ffe7088c8..9a717cc53a8 --- a/src/app/filters/all.js +++ b/src/app/filters/all.js @@ -114,4 +114,10 @@ define(['angular', 'jquery', 'underscore', 'moment'], function (angular, $, _, m }; }); + module.filter('urlDecode', function() { + return function(input) { + return decodeURIComponent(input); + }; + }); + }); \ No newline at end of file diff --git a/src/app/panels/filtering/module.html b/src/app/panels/filtering/module.html old mode 100644 new mode 100755 index a360161aa83..6f8dd5d79fb --- a/src/app/panels/filtering/module.html +++ b/src/app/panels/filtering/module.html @@ -17,7 +17,7 @@ diff --git a/src/app/panels/graphite/legend.html b/src/app/panels/graphite/legend.html old mode 100644 new mode 100755 index 84aab5020f6..013b50a5c95 --- a/src/app/panels/graphite/legend.html +++ b/src/app/panels/graphite/legend.html @@ -9,7 +9,7 @@ - {{series.alias}} + {{series.alias | urlDecode }} diff --git a/src/app/partials/graphite/editor.html b/src/app/partials/graphite/editor.html old mode 100644 new mode 100755 index 48179eccacf..3503680b424 --- a/src/app/partials/graphite/editor.html +++ b/src/app/partials/graphite/editor.html @@ -70,7 +70,7 @@ From b38f6e8062b9ec3890372849a27f84004ab995cf Mon Sep 17 00:00:00 2001 From: "Haneysmith, Nathan" Date: Mon, 2 Jun 2014 16:01:42 -0700 Subject: [PATCH 2/6] add graphite function isNonNull --- src/app/services/graphite/gfunc.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/app/services/graphite/gfunc.js b/src/app/services/graphite/gfunc.js index e2d7b072e6d..748f6085a7b 100644 --- a/src/app/services/graphite/gfunc.js +++ b/src/app/services/graphite/gfunc.js @@ -69,6 +69,11 @@ function (_) { category: categories.Combine, }); + addFuncDef({ + name: 'isNonNull', + category: categories.Combine, + }); + addFuncDef({ name: 'rangeOfSeries', category: categories.Combine From 8911da8380a612c3087d4491170162c4272e3b54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Tue, 3 Jun 2014 06:08:42 -0700 Subject: [PATCH 3/6] updated changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 113ae78df1f..e35ad54a54e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ vNext - Allow special characters in serie names (influxdb datasource), PR #390 - thx @majst01 - Refactoring of filterSrv (Issue #428), thx @Tetha - New config for playlist feature. Set playlist_timespan to set default playlist interval (Issue #445) - thx @rmca +- New graphite function definition added isNonNull (PR #461), - thx @tmonk42 # Fixes - Filter option loading when having muliple nested filters now works better. From 7137a9986f3b70a3ff23e707f4342b0ac902d03d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Tue, 3 Jun 2014 06:28:16 -0700 Subject: [PATCH 4/6] Fix to series toggling bug that caused annotations to be hidden when toggling (hiding) series. Fixes #328 --- CHANGELOG.md | 1 + src/app/directives/grafanaGraph.js | 13 +++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 466113dc3a6..18933684bf9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ vNext After an option is changed and a nested template param is also reloaded, if the current value exists after the options are reloaded the current selected value is kept (Closes #447, Closes #412) - Legend Current value did not display when value was zero, Fixes #460 +- Fix to series toggling bug that caused annotations to be hidden when toggling (hiding) series. Fixes #328 # 1.5.4 (2014-05-13) ### New features and improvements diff --git a/src/app/directives/grafanaGraph.js b/src/app/directives/grafanaGraph.js index 798584ca194..69c74c7bcf5 100644 --- a/src/app/directives/grafanaGraph.js +++ b/src/app/directives/grafanaGraph.js @@ -15,7 +15,7 @@ function (angular, $, kbn, moment, _) { restrict: 'A', template: '
', link: function(scope, elem) { - var data, plot; + var data, plot, annotations; var hiddenData = {}; scope.$on('refresh',function() { @@ -35,8 +35,9 @@ function (angular, $, kbn, moment, _) { }); // Receive render events - scope.$on('render',function(event, d) { - data = d || data; + scope.$on('render',function(event, renderData) { + data = renderData || data; + annotations = renderData.annotations; render_panel(); }); @@ -206,13 +207,13 @@ function (angular, $, kbn, moment, _) { } function addAnnotations(options) { - if(!data.annotations || data.annotations.length === 0) { + if(!annotations || annotations.length === 0) { return; } var types = {}; - _.each(data.annotations, function(event) { + _.each(annotations, function(event) { if (!types[event.annotation.name]) { types[event.annotation.name] = { level: _.keys(types).length + 1, @@ -235,7 +236,7 @@ function (angular, $, kbn, moment, _) { options.events = { levels: _.keys(types).length + 1, - data: data.annotations, + data: annotations, types: types }; } From c48b3ded2f67544825bb7a1f76d551c1f4a3d9c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Tue, 3 Jun 2014 19:07:59 -0700 Subject: [PATCH 5/6] Fix for graphite function selection menu that some times draws outside screen. It now displays upward (Fixes #293) --- CHANGELOG.md | 1 + src/app/directives/addGraphiteFunc.js | 2 +- src/app/directives/bootstrap-tagsinput.js | 17 +++++++++-------- src/app/directives/grafanaGraph.js | 2 +- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 18933684bf9..bbe1d57cfae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ vNext exists after the options are reloaded the current selected value is kept (Closes #447, Closes #412) - Legend Current value did not display when value was zero, Fixes #460 - Fix to series toggling bug that caused annotations to be hidden when toggling (hiding) series. Fixes #328 +- Fix for graphite function selection menu that some times draws outside screen. It now displays upward (Fixes #293) # 1.5.4 (2014-05-13) ### New features and improvements diff --git a/src/app/directives/addGraphiteFunc.js b/src/app/directives/addGraphiteFunc.js index 6ea24a18cfe..f5801bb3106 100644 --- a/src/app/directives/addGraphiteFunc.js +++ b/src/app/directives/addGraphiteFunc.js @@ -18,7 +18,7 @@ function (angular, app, _, $, gfunc) { var buttonTemplate = ''; + ' data-placement="top">'; return { link: function($scope, elem) { diff --git a/src/app/directives/bootstrap-tagsinput.js b/src/app/directives/bootstrap-tagsinput.js index 5012fa03212..95dc78a6bf7 100644 --- a/src/app/directives/bootstrap-tagsinput.js +++ b/src/app/directives/bootstrap-tagsinput.js @@ -87,13 +87,12 @@ function (angular, $) { .module('kibana.directives') .directive('gfDropdown', function ($parse, $compile, $timeout) { - function buildTemplate(items, ul) { - if (!ul) { - ul = [ - '' - ]; - } + function buildTemplate(items, placement) { + var upclass = placement === 'top' ? 'dropup' : ''; + var ul = [ + '' + ]; angular.forEach(items, function (item, index) { if (item.divider) { @@ -122,10 +121,12 @@ function (angular, $) { link: function postLink(scope, iElement, iAttrs) { var getter = $parse(iAttrs.gfDropdown), items = getter(scope); $timeout(function () { - var dropdown = angular.element(buildTemplate(items).join('')); + var placement = iElement.data('placement'); + var dropdown = angular.element(buildTemplate(items, placement).join('')); dropdown.insertAfter(iElement); $compile(iElement.next('ul.dropdown-menu'))(scope); }); + iElement.addClass('dropdown-toggle').attr('data-toggle', 'dropdown'); } }; diff --git a/src/app/directives/grafanaGraph.js b/src/app/directives/grafanaGraph.js index 69c74c7bcf5..ca9da221ac6 100644 --- a/src/app/directives/grafanaGraph.js +++ b/src/app/directives/grafanaGraph.js @@ -37,7 +37,7 @@ function (angular, $, kbn, moment, _) { // Receive render events scope.$on('render',function(event, renderData) { data = renderData || data; - annotations = renderData.annotations; + annotations = data.annotations; render_panel(); }); From c2b8f21fd96639cfbf81afb168788773f277373f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Thu, 5 Jun 2014 20:50:14 -0700 Subject: [PATCH 6/6] small changes to PR #327, Partial support for url encoded metric names when using graphite datasource --- CHANGELOG.md | 1 + src/app/directives/grafanaGraph.js | 2 +- src/app/filters/all.js | 2 +- src/app/panels/graphite/legend.html | 2 +- src/app/partials/graphite/editor.html | 2 +- src/app/services/graphite/graphiteDatasource.js | 2 +- src/app/services/graphite/lexer.js | 1 + 7 files changed, 7 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bbe1d57cfae..4e12da99428 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ vNext - Added parameter to keepLastValue graphite function definition (default 100), Closes #459 - improved asset (css/js) build pipeline, added revision to css and js. Will remove issues related to the browser cache when upgrading grafana and improve load performance (Fixes #418) +- Partial support for url encoded metrics when using Graphite datasource (PR #327) - thx @axe-felix # Fixes - Filter option loading when having muliple nested filters now works better. diff --git a/src/app/directives/grafanaGraph.js b/src/app/directives/grafanaGraph.js index f600aebe433..b27ed32d352 100755 --- a/src/app/directives/grafanaGraph.js +++ b/src/app/directives/grafanaGraph.js @@ -314,7 +314,7 @@ function (angular, $, kbn, moment, _) { if (seriesInfo.alias) { group = '' + '' + ' ' + - (decodeURIComponent(seriesInfo.alias) || seriesInfo.query)+ + (decodeURIComponent(seriesInfo.alias)) + '
'; } else { group = kbn.query_color_dot(item.series.color, 15) + ' '; diff --git a/src/app/filters/all.js b/src/app/filters/all.js index 9a717cc53a8..0a6dd12b816 100755 --- a/src/app/filters/all.js +++ b/src/app/filters/all.js @@ -118,6 +118,6 @@ define(['angular', 'jquery', 'underscore', 'moment'], function (angular, $, _, m return function(input) { return decodeURIComponent(input); }; - }); + }); }); \ No newline at end of file diff --git a/src/app/panels/graphite/legend.html b/src/app/panels/graphite/legend.html index 013b50a5c95..45eca738848 100755 --- a/src/app/panels/graphite/legend.html +++ b/src/app/panels/graphite/legend.html @@ -9,7 +9,7 @@ - {{series.alias | urlDecode }} + {{series.alias | urlDecode}} diff --git a/src/app/partials/graphite/editor.html b/src/app/partials/graphite/editor.html index 3503680b424..48179eccacf 100755 --- a/src/app/partials/graphite/editor.html +++ b/src/app/partials/graphite/editor.html @@ -70,7 +70,7 @@ diff --git a/src/app/services/graphite/graphiteDatasource.js b/src/app/services/graphite/graphiteDatasource.js index 78984a55cf7..6d2c76f9af4 100644 --- a/src/app/services/graphite/graphiteDatasource.js +++ b/src/app/services/graphite/graphiteDatasource.js @@ -118,7 +118,7 @@ function (angular, _, $, config, kbn, moment) { GraphiteDatasource.prototype.metricFindQuery = function(filterSrv, query) { var interpolated; try { - interpolated = filterSrv.applyTemplateToTarget(query); + interpolated = encodeURIComponent(filterSrv.applyTemplateToTarget(query)); } catch(err) { return $q.reject(err); diff --git a/src/app/services/graphite/lexer.js b/src/app/services/graphite/lexer.js index 91cd2237bfe..3cc3a1a2774 100644 --- a/src/app/services/graphite/lexer.js +++ b/src/app/services/graphite/lexer.js @@ -124,6 +124,7 @@ define([ i === 45 || // - i === 42 || // * i === 58 || // : + i === 37 || // % i >= 97 && i <= 122; // a-z }