diff --git a/public/app/plugins/datasource/elasticsearch/datasource.js b/public/app/plugins/datasource/elasticsearch/datasource.js index d70c781ca6d..3f873823096 100644 --- a/public/app/plugins/datasource/elasticsearch/datasource.js +++ b/public/app/plugins/datasource/elasticsearch/datasource.js @@ -300,14 +300,21 @@ function (angular, _, config, kbn, moment, ElasticQueryBuilder) { if (target.hide) { return []; } var queryBuilder = new ElasticQueryBuilder(target); var query = queryBuilder.build(); + console.log(target); query = query.replace(/\$interval/g, target.interval || options.interval); query = query.replace(/\$rangeFrom/g, options.range.from); query = query.replace(/\$rangeTo/g, options.range.to); query = query.replace(/\$maxDataPoints/g, options.maxDataPoints); + query = query.replace(/\$keyField/g, target.keyField); + query = query.replace(/\$valueField/g, target.valueField); + query = query.replace(/\$termKey/g, target.termKey); + query = query.replace(/\$termValue/g, target.termValue); query = templateSrv.replace(query, options.scopedVars); return query; }).join("\n"); + console.log(allQueries); + return this._post('/_search?search_type=count', allQueries).then(function(results) { if (!results || !results.facets) { return { data: [] }; diff --git a/public/app/plugins/datasource/elasticsearch/partials/query.editor.html b/public/app/plugins/datasource/elasticsearch/partials/query.editor.html index ac74c3d661d..b9450f3d3ef 100644 --- a/public/app/plugins/datasource/elasticsearch/partials/query.editor.html +++ b/public/app/plugins/datasource/elasticsearch/partials/query.editor.html @@ -63,7 +63,7 @@