diff --git a/public/app/plugins/datasource/cloudwatch/partials/query.editor.html b/public/app/plugins/datasource/cloudwatch/partials/query.editor.html
index bc32e4f9d50..84fcbdbbc25 100644
--- a/public/app/plugins/datasource/cloudwatch/partials/query.editor.html
+++ b/public/app/plugins/datasource/cloudwatch/partials/query.editor.html
@@ -97,7 +97,7 @@
Dimensions
-
+
{{key}} = {{value}}
diff --git a/public/app/plugins/datasource/cloudwatch/queryCtrl.js b/public/app/plugins/datasource/cloudwatch/queryCtrl.js
index 2a7255c49b5..c5e672416d1 100644
--- a/public/app/plugins/datasource/cloudwatch/queryCtrl.js
+++ b/public/app/plugins/datasource/cloudwatch/queryCtrl.js
@@ -13,6 +13,7 @@ function (angular, _) {
$scope.target.namespace = $scope.target.namespace || '';
$scope.target.metricName = $scope.target.metricName || '';
$scope.target.dimensions = $scope.target.dimensions || {};
+ $scope.target.escapedDimensions = this.escapeDimensions($scope.target.dimensions);
$scope.target.statistics = $scope.target.statistics || {};
$scope.target.period = $scope.target.period || 60;
$scope.target.region = $scope.target.region || $scope.datasource.getDefaultRegion();
@@ -94,6 +95,7 @@ function (angular, _) {
}
$scope.target.dimensions[$scope.target.currentDimensionKey] = $scope.target.currentDimensionValue;
+ $scope.target.escapedDimensions = this.escapeDimensions($scope.target.dimensions);
$scope.target.currentDimensionKey = '';
$scope.target.currentDimensionValue = '';
$scope.refreshMetricData();
@@ -102,10 +104,24 @@ function (angular, _) {
};
$scope.removeDimension = function(key) {
+ key = key.replace(/\\\$/g, '$');
delete $scope.target.dimensions[key];
+ $scope.target.escapedDimensions = this.escapeDimensions($scope.target.dimensions);
$scope.refreshMetricData();
};
+ $scope.escapeDimensions = function(d) {
+ var result = {};
+ _.chain(d)
+ .keys(d)
+ .each(function(k) {
+ var v = d[k];
+ result[k.replace(/\$/g, '\\$')] = v.replace(/\$/g, '\\$');
+ });
+
+ return result;
+ };
+
$scope.statisticsOptionChanged = function() {
$scope.refreshMetricData();
};