From ea7fe0c7614459637788855675e47b929cdbfcb9 Mon Sep 17 00:00:00 2001 From: ubhatnagar Date: Thu, 24 Sep 2015 09:40:09 +0530 Subject: [PATCH 1/2] Single stat panel throws warning on multiple series result. --- public/app/panels/singlestat/module.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/public/app/panels/singlestat/module.js b/public/app/panels/singlestat/module.js index 152a12ab44f..0e18804df11 100644 --- a/public/app/panels/singlestat/module.js +++ b/public/app/panels/singlestat/module.js @@ -171,6 +171,12 @@ function (angular, app, _, kbn, TimeSeries, PanelMeta) { $scope.render = function() { var data = {}; + if($scope.series.length > 1) { + $scope.appEvent('alert-warning', ['Multiple Series Error', 'Metric query returns ' + + $scope.series.length + ' series. Single Stat Panel expects a single series.']); + $scope.series = []; + } + $scope.setValues(data); data.thresholds = $scope.panel.thresholds.split(',').map(function(strVale) { @@ -185,7 +191,6 @@ function (angular, app, _, kbn, TimeSeries, PanelMeta) { $scope.setValues = function(data) { data.flotpairs = []; - if ($scope.series && $scope.series.length > 0) { var lastPoint = _.last($scope.series[0].datapoints); var lastValue = _.isArray(lastPoint) ? lastPoint[0] : null; From 026fffa19f903837866aed994ffabafbdf9465ec Mon Sep 17 00:00:00 2001 From: ubhatnagar Date: Thu, 24 Sep 2015 23:13:05 +0530 Subject: [PATCH 2/2] Singlestat Panel Error in InspectCtrl. --- public/app/panels/singlestat/module.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/public/app/panels/singlestat/module.js b/public/app/panels/singlestat/module.js index 0e18804df11..f065d2cb653 100644 --- a/public/app/panels/singlestat/module.js +++ b/public/app/panels/singlestat/module.js @@ -171,12 +171,6 @@ function (angular, app, _, kbn, TimeSeries, PanelMeta) { $scope.render = function() { var data = {}; - if($scope.series.length > 1) { - $scope.appEvent('alert-warning', ['Multiple Series Error', 'Metric query returns ' + - $scope.series.length + ' series. Single Stat Panel expects a single series.']); - $scope.series = []; - } - $scope.setValues(data); data.thresholds = $scope.panel.thresholds.split(',').map(function(strVale) { @@ -191,6 +185,15 @@ function (angular, app, _, kbn, TimeSeries, PanelMeta) { $scope.setValues = function(data) { data.flotpairs = []; + + if($scope.series.length > 1) { + $scope.inspector.error = new Error(); + $scope.inspector.error.message = 'Multiple Series Error'; + $scope.inspector.error.data = 'Metric query returns ' + $scope.series.length + + ' series. Single Stat Panel expects a single series.\n\nResponse:\n'+JSON.stringify($scope.series); + throw $scope.inspector.error; + } + if ($scope.series && $scope.series.length > 0) { var lastPoint = _.last($scope.series[0].datapoints); var lastValue = _.isArray(lastPoint) ? lastPoint[0] : null;