Commit 6f923ecd by Torkel Ödegaard

Merge pull request #3901 from bobrik/opentsdb-tag-name-suggestions

Show relevant tag name suggestions for OpenTSDB, closes #3610
parents 501f21b1 f4ad673b
......@@ -15,6 +15,7 @@ function (angular, _, dateMath) {
this.withCredentials = instanceSettings.withCredentials;
this.basicAuth = instanceSettings.basicAuth;
this.supportMetrics = true;
this.tagKeys = {};
// Called once per panel (graph)
this.query = function(options) {
......@@ -50,10 +51,13 @@ function (angular, _, dateMath) {
if (index === -1) {
index = 0;
}
this._saveTagKeys(metricData);
return transformMetricData(metricData, groupByTags, options.targets[index], options);
});
}.bind(this));
return { data: result };
});
}.bind(this));
};
this.performTimeSeriesQuery = function(queries, start, end) {
......@@ -87,6 +91,19 @@ function (angular, _, dateMath) {
return backendSrv.datasourceRequest(options);
};
this.suggestTagKeys = function(metric) {
return $q.when(this.tagKeys[metric] || []);
};
this._saveTagKeys = function(metricData) {
var tagKeys = Object.keys(metricData.tags);
_.each(metricData.aggregateTags, function(tag) {
tagKeys.push(tag);
});
this.tagKeys[metricData.metric] = tagKeys;
};
this._performSuggestQuery = function(query, type) {
return this._get('/api/suggest', {type: type, q: query, max: 1000}).then(function(result) {
return result.data;
......
......@@ -50,9 +50,7 @@ export class OpenTsQueryCtrl extends QueryCtrl {
};
this.suggestTagKeys = (query, callback) => {
this.datasource.metricFindQuery('suggest_tagk(' + query + ')')
.then(this.getTextValues)
.then(callback);
this.datasource.suggestTagKeys(this.target.metric).then(callback);
};
this.suggestTagValues = (query, callback) => {
......
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