From b3e459863e230571f505d4f632258eca976cc72c Mon Sep 17 00:00:00 2001 From: Todd Persen Date: Fri, 28 Mar 2014 01:13:11 -0400 Subject: [PATCH] Add support for multiple hosts (with retries) and raw queries. --- src/app/components/settings.js | 6 + src/app/controllers/influxTargetCtrl.js | 12 +- src/app/partials/influxdb/editor.html | 56 +++++--- .../services/influxdb/influxdbDatasource.js | 125 ++++++++++++------ 4 files changed, 140 insertions(+), 59 deletions(-) diff --git a/src/app/components/settings.js b/src/app/components/settings.js index 18fbf5e48a6..b7785d5ce4b 100644 --- a/src/app/components/settings.js +++ b/src/app/components/settings.js @@ -49,6 +49,11 @@ function (_, crypto) { return datasource; }; + var parseMultipleHosts = function(datasource) { + datasource.urls = _.map(datasource.url.split(","), function (url) { return url.trim(); }); + return datasource; + }; + if (options.graphiteUrl) { settings.datasources = { graphite: { @@ -62,6 +67,7 @@ function (_, crypto) { _.each(settings.datasources, function(datasource, key) { datasource.name = key; parseBasicAuth(datasource); + if (datasource.type === 'influxdb') { parseMultipleHosts(datasource); } }); var elasticParsed = parseBasicAuth({ url: settings.elasticsearch }); diff --git a/src/app/controllers/influxTargetCtrl.js b/src/app/controllers/influxTargetCtrl.js index 5d96a280470..7ad82ae6807 100644 --- a/src/app/controllers/influxTargetCtrl.js +++ b/src/app/controllers/influxTargetCtrl.js @@ -15,6 +15,8 @@ function (angular) { $scope.target.function = 'mean'; } + $scope.rawQuery = false; + $scope.functions = ['count', 'mean', 'sum', 'min', 'max', 'mode', 'distinct', 'median', 'derivative', 'stddev', 'first', 'last']; $scope.oldSeries = $scope.target.series; $scope.$on('typeahead-updated', function(){ @@ -22,6 +24,14 @@ function (angular) { }); }; + $scope.showQuery = function () { + $scope.target.rawQuery = true; + }; + + $scope.hideQuery = function () { + $scope.target.rawQuery = false; + }; + // Cannot use typeahead and ng-change on blur at the same time $scope.seriesBlur = function() { if ($scope.oldSeries !== $scope.target.series) { @@ -65,4 +75,4 @@ function (angular) { }); -}); \ No newline at end of file +}); diff --git a/src/app/partials/influxdb/editor.html b/src/app/partials/influxdb/editor.html index d34d6ab5f9b..80dd46b87e2 100644 --- a/src/app/partials/influxdb/editor.html +++ b/src/app/partials/influxdb/editor.html @@ -11,17 +11,16 @@