mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Merge pull request #4054 from mtanda/cloudwatch_template_dimension_fix
(cloudwatch) fix template replace in legend
This commit is contained in:
@@ -58,7 +58,7 @@ function (angular, _, moment, dateMath) {
|
||||
var result = [];
|
||||
|
||||
_.each(allResponse, function(response, index) {
|
||||
var metrics = transformMetricData(response, options.targets[index]);
|
||||
var metrics = transformMetricData(response, options.targets[index], options.scopedVars);
|
||||
result = result.concat(metrics);
|
||||
});
|
||||
|
||||
@@ -302,15 +302,21 @@ function (angular, _, moment, dateMath) {
|
||||
return this.defaultRegion;
|
||||
};
|
||||
|
||||
function transformMetricData(md, options) {
|
||||
function transformMetricData(md, options, scopedVars) {
|
||||
var aliasRegex = /\{\{(.+?)\}\}/g;
|
||||
var aliasPattern = options.alias || '{{metric}}_{{stat}}';
|
||||
var aliasData = {
|
||||
region: templateSrv.replace(options.region),
|
||||
namespace: templateSrv.replace(options.namespace),
|
||||
metric: templateSrv.replace(options.metricName),
|
||||
region: templateSrv.replace(options.region, scopedVars),
|
||||
namespace: templateSrv.replace(options.namespace, scopedVars),
|
||||
metric: templateSrv.replace(options.metricName, scopedVars),
|
||||
};
|
||||
_.extend(aliasData, options.dimensions);
|
||||
var aliasDimensions = {};
|
||||
_.each(_.keys(options.dimensions), function(origKey) {
|
||||
var key = templateSrv.replace(origKey, scopedVars);
|
||||
var value = templateSrv.replace(options.dimensions[origKey], scopedVars);
|
||||
aliasDimensions[key] = value;
|
||||
});
|
||||
_.extend(aliasData, aliasDimensions);
|
||||
|
||||
var periodMs = options.period * 1000;
|
||||
return _.map(options.statistics, function(stat) {
|
||||
|
||||
Reference in New Issue
Block a user