Commit de00d18a by Mathieu Chataigner

adding templating in opentsdb graphs

parent 920e5c93
define([ define([
'angular', 'angular',
'lodash', 'lodash',
'kbn' 'kbn',
'moment'
], ],
function (angular, _, kbn) { function (angular, _, kbn, moment) {
'use strict'; 'use strict';
var module = angular.module('grafana.services'); var module = angular.module('grafana.services');
module.factory('OpenTSDBDatasource', function($q, $http) { module.factory('OpenTSDBDatasource', function($q, $http, templateSrv) {
function OpenTSDBDatasource(datasource) { function OpenTSDBDatasource(datasource) {
this.type = 'opentsdb'; this.type = 'opentsdb';
...@@ -123,12 +124,12 @@ function (angular, _, kbn) { ...@@ -123,12 +124,12 @@ function (angular, _, kbn) {
} }
var query = { var query = {
metric: target.metric, metric: templateSrv.replace(target.metric),
aggregator: "avg" aggregator: "avg"
}; };
if (target.aggregator) { if (target.aggregator) {
query.aggregator = target.aggregator; query.aggregator = templateSrv.replace(target.aggregator);
} }
if (target.shouldComputeRate) { if (target.shouldComputeRate) {
...@@ -143,6 +144,11 @@ function (angular, _, kbn) { ...@@ -143,6 +144,11 @@ function (angular, _, kbn) {
} }
query.tags = angular.copy(target.tags); query.tags = angular.copy(target.tags);
if(query.tags){
for(var key in query.tags){
query.tags[key] = templateSrv.replace(query.tags[key]);
}
}
return query; return query;
} }
......
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