diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e460999994..9564f1d932d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# 2.0.0 (unreleased) + +**Enhancements** +- [Issue #1297](https://github.com/grafana/grafana/issues/1297). Graphite: Added cumulative and minimumBelow graphite functions +- [Issue #1296](https://github.com/grafana/grafana/issues/1296). InfluxDB: Auto escape column names with special characters. Thanks @steven-aerts + # 1.9.1 (2014-12-29) **Enhancements** diff --git a/src/app/components/lodash.extended.js b/src/app/components/lodash.extended.js index 40372239672..4edae35f02d 100644 --- a/src/app/components/lodash.extended.js +++ b/src/app/components/lodash.extended.js @@ -14,10 +14,6 @@ function () { array.splice(toIndex, 0, array.splice(fromIndex, 1)[0]); return array; }, - remove: function (array, index) { - array.splice(index, 1); - return array; - }, // If variable is value, then return alt. If variable is anything else, return value; toggle: function (variable, value, alt) { return variable === value ? alt : value; diff --git a/src/app/features/graphite/datasource.js b/src/app/features/graphite/datasource.js index 68fd9a2890f..639e150a320 100644 --- a/src/app/features/graphite/datasource.js +++ b/src/app/features/graphite/datasource.js @@ -232,7 +232,10 @@ function (angular, _, $, config, kbn, moment) { '#A', '#B', '#C', '#D', '#E', '#F', '#G', '#H', '#I', '#J', '#K', '#L', - '#M', '#N', '#O' + '#M', '#N', '#O', '#P', + '#Q', '#R', '#S', '#T', + '#U', '#V', '#W', '#X', + '#Y', '#Z' ]; GraphiteDatasource.prototype.buildGraphiteParams = function(options) { diff --git a/src/app/features/graphite/gfunc.js b/src/app/features/graphite/gfunc.js index dc912f9328c..7190fbf0295 100644 --- a/src/app/features/graphite/gfunc.js +++ b/src/app/features/graphite/gfunc.js @@ -223,6 +223,13 @@ function (_, $) { defaultParams: ['max'] }); + addFuncDef({ + name: "cumulative", + category: categories.Special, + params: [], + defaultParams: [] + }); + addFuncDef({ name: "groupByNode", category: categories.Special, @@ -467,6 +474,13 @@ function (_, $) { defaultParams: [0] }); + addFuncDef({ + name: 'minimumBelow', + category: categories.Filter, + params: [{ name: "value", type: "int" }], + defaultParams: [0] + }); + addFuncDef({ name: 'limit', category: categories.Filter, diff --git a/src/app/features/graphite/queryCtrl.js b/src/app/features/graphite/queryCtrl.js index e270c555aa6..0654c474af5 100644 --- a/src/app/features/graphite/queryCtrl.js +++ b/src/app/features/graphite/queryCtrl.js @@ -9,7 +9,7 @@ function (angular, _, config, gfunc, Parser) { 'use strict'; var module = angular.module('grafana.controllers'); - var targetLetters = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O']; + var targetLetters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; module.controller('GraphiteQueryCtrl', function($scope, $sce, templateSrv) { diff --git a/src/app/features/influxdb/datasource.js b/src/app/features/influxdb/datasource.js index dc542ec3cfd..3de499ff40e 100644 --- a/src/app/features/influxdb/datasource.js +++ b/src/app/features/influxdb/datasource.js @@ -74,16 +74,19 @@ function (angular, _, kbn, InfluxSeries, InfluxQueryBuilder) { }; InfluxDatasource.prototype.listColumns = function(seriesName) { - var interpolated = templateSrv.replace(seriesName); - if (interpolated[0] !== '/') { - interpolated = '/' + interpolated + '/'; + seriesName = templateSrv.replace(seriesName); + + if(!seriesName.match('^/.*/') && !seriesName.match(/^merge\(.*\)/)) { + seriesName = '"' + seriesName+ '"'; } - return this._seriesQuery('select * from ' + interpolated + ' limit 1').then(function(data) { + return this._seriesQuery('select * from ' + seriesName + ' limit 1').then(function(data) { if (!data) { return []; } - return data[0].columns; + return data[0].columns.map(function(item) { + return /^\w+$/.test(item) ? item : ('"' + item + '"'); + }); }); }; @@ -97,17 +100,9 @@ function (angular, _, kbn, InfluxSeries, InfluxQueryBuilder) { if (!data || data.length === 0) { return []; } - // influxdb >= 1.8 - if (data[0].points.length > 0) { - return _.map(data[0].points, function(point) { - return point[1]; - }); - } - else { // influxdb <= 1.7 - return _.map(data, function(series) { - return series.name; // influxdb < 1.7 - }); - } + return _.map(data[0].points, function(point) { + return point[1]; + }); }); }; diff --git a/src/app/features/influxdb/queryCtrl.js b/src/app/features/influxdb/queryCtrl.js index 0d33445117b..89bd572f4e5 100644 --- a/src/app/features/influxdb/queryCtrl.js +++ b/src/app/features/influxdb/queryCtrl.js @@ -88,7 +88,6 @@ function (angular, _) { seriesList = []; $scope.datasource.listSeries(query).then(function(series) { seriesList = series; - console.log(series); callback(seriesList); }); } diff --git a/src/app/services/alertSrv.js b/src/app/services/alertSrv.js index 74b3308c4e8..6d5801ad649 100644 --- a/src/app/services/alertSrv.js +++ b/src/app/services/alertSrv.js @@ -27,28 +27,27 @@ function (angular, _) { this.list = []; this.set = function(title,text,severity,timeout) { - var - _a = { - title: title || '', - text: $sce.trustAsHtml(text || ''), - severity: severity || 'info', - }, - _ca = angular.toJson(_a), - _clist = _.map(self.list,function(alert) {return angular.toJson(alert);}); + var newAlert = { + title: title || '', + text: $sce.trustAsHtml(text || ''), + severity: severity || 'info', + }; - // If we already have this alert, remove it and add a new one - // Why do this instead of skipping the add because it resets the timer - if(_.contains(_clist,_ca)) { - _.remove(self.list,_.indexOf(_clist,_ca)); - } + var newAlertJson = angular.toJson(newAlert); - self.list.push(_a); + // remove same alert if it already exists + _.remove(self.list, function(value) { + return angular.toJson(value) === newAlertJson; + }); + + self.list.push(newAlert); if (timeout > 0) { $timeout(function() { - self.list = _.without(self.list,_a); + self.list = _.without(self.list,newAlert); }, timeout); } - return(_a); + + return(newAlert); }; this.clear = function(alert) {