diff --git a/public/app/plugins/datasource/cloudwatch/datasource.js b/public/app/plugins/datasource/cloudwatch/datasource.js index c4f3a82f98e..fde9e8f09ea 100644 --- a/public/app/plugins/datasource/cloudwatch/datasource.js +++ b/public/app/plugins/datasource/cloudwatch/datasource.js @@ -358,9 +358,15 @@ function (angular, _, moment, dateMath, kbn, CloudWatchAnnotationQuery) { } this.getExpandedVariables = function(target, dimensionKey, variable) { + /* if the all checkbox is marked we should add all values to the targets */ + var allSelected = _.find(variable.options, {'selected': true, 'text': 'All'}); return _.chain(variable.options) .filter(function(v) { - return v.selected; + if (allSelected) { + return v.text !== 'All'; + } else { + return v.selected; + } }) .map(function(v) { var t = angular.copy(target); @@ -369,6 +375,10 @@ function (angular, _, moment, dateMath, kbn, CloudWatchAnnotationQuery) { }).value(); }; + this.containsVariable = function (str, variableName) { + return str.indexOf('$' + variableName) !== -1; + }; + this.expandTemplateVariable = function(targets, templateSrv) { var self = this; return _.chain(targets) @@ -379,7 +389,7 @@ function (angular, _, moment, dateMath, kbn, CloudWatchAnnotationQuery) { if (dimensionKey) { var variable = _.find(templateSrv.variables, function(variable) { - return templateSrv.containsVariable(target.dimensions[dimensionKey], variable.name); + return self.containsVariable(target.dimensions[dimensionKey], variable.name); }); return self.getExpandedVariables(target, dimensionKey, variable); } else {