Commit d98d8a40 by Mitsuhiro Tanda

fix dimension convertion

parent c140d7aa
......@@ -335,14 +335,14 @@ func (e *CloudWatchExecutor) handleGetDimensionValues(ctx context.Context, param
namespace := parameters.Get("namespace").MustString()
metricName := parameters.Get("metricName").MustString()
dimensionKey := parameters.Get("dimensionKey").MustString()
dimensionsJson := parameters.Get("dimensionKey").MustMap()
dimensionsJson := parameters.Get("dimensions").MustMap()
var dimensions []*cloudwatch.DimensionFilter
for _, d := range dimensionsJson {
if dd, ok := d.(map[string]string); ok {
for k, v := range dimensionsJson {
if vv, ok := v.(string); ok {
dimensions = append(dimensions, &cloudwatch.DimensionFilter{
Name: aws.String(dd["Name"]),
Value: aws.String(dd["Value"]),
Name: aws.String(k),
Value: aws.String(vv),
})
}
}
......
......@@ -40,11 +40,7 @@ function (angular, _, moment, dateMath, kbn, templatingVariable) {
item.region = templateSrv.replace(item.region, options.scopedVars);
item.namespace = templateSrv.replace(item.namespace, options.scopedVars);
item.metricName = templateSrv.replace(item.metricName, options.scopedVars);
var dimensions = {};
_.each(item.dimensions, function (value, key) {
dimensions[templateSrv.replace(key, options.scopedVars)] = templateSrv.replace(value, options.scopedVars);
});
item.dimensions = dimensions;
item.dimensions = self.convertDimensionFormat(item.dimensions, options.scopeVars);
item.period = self.getPeriod(item, options);
return _.extend({
......@@ -266,16 +262,12 @@ function (angular, _, moment, dateMath, kbn, templatingVariable) {
var defaultPeriod = annotation.prefixMatching ? '' : '300';
var period = annotation.period || defaultPeriod;
period = parseInt(period, 10);
var dimensions = {};
_.each(annotation.dimensions, function (value, key) {
dimensions[templateSrv.replace(key, options.scopedVars)] = templateSrv.replace(value, options.scopedVars);
});
var parameters = {
prefixMatching: annotation.prefixMatching,
region: templateSrv.replace(annotation.region),
namespace: templateSrv.replace(annotation.namespace),
metricName: templateSrv.replace(annotation.metricName),
dimensions: dimensions,
dimensions: this.convertDimensionFormat(annotation.dimensions, {}),
statistics: _.map(annotation.statistics, function (s) { return templateSrv.replace(s); }),
period: period,
actionPrefix: annotation.actionPrefix || '',
......@@ -385,12 +377,11 @@ function (angular, _, moment, dateMath, kbn, templatingVariable) {
};
this.convertDimensionFormat = function(dimensions, scopedVars) {
return _.map(dimensions, function(value, key) {
return {
Name: templateSrv.replace(key, scopedVars),
Value: templateSrv.replace(value, scopedVars)
};
var convertedDimensions = {};
_.each(dimensions, function (value, key) {
convertedDimensions[templateSrv.replace(key, scopedVars)] = templateSrv.replace(value, scopedVars);
});
return convertedDimensions;
};
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment