mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Merge branch 'lexh-restrict-tag-keys-values'
This commit is contained in:
commit
f58e228d11
@ -90,6 +90,55 @@ function (angular, _, kbn) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
OpenTSDBDatasource.prototype.performMetricKeyValueLookup = function(metric, key) {
|
||||||
|
if(!metric || !key) {
|
||||||
|
return $q.when([]);
|
||||||
|
}
|
||||||
|
|
||||||
|
var m = metric + "{" + key + "=*}";
|
||||||
|
var options = {
|
||||||
|
method: 'GET',
|
||||||
|
url: this.url + '/api/search/lookup',
|
||||||
|
params: {
|
||||||
|
m: m,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return backendSrv.datasourceRequest(options).then(function(result) {
|
||||||
|
result = result.data.results;
|
||||||
|
var tagvs = [];
|
||||||
|
_.each(result, function(r) {
|
||||||
|
tagvs.push(r.tags[key]);
|
||||||
|
});
|
||||||
|
return tagvs;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
OpenTSDBDatasource.prototype.performMetricKeyLookup = function(metric) {
|
||||||
|
if(metric === "") {
|
||||||
|
throw "Metric not set.";
|
||||||
|
}
|
||||||
|
var options = {
|
||||||
|
method: 'GET',
|
||||||
|
url: this.url + '/api/search/lookup',
|
||||||
|
params: {
|
||||||
|
m: metric,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return backendSrv.datasourceRequest(options).then(function(result) {
|
||||||
|
result = result.data.results;
|
||||||
|
var tagks = [];
|
||||||
|
_.each(result, function(r) {
|
||||||
|
_.each(r.tags, function(tagv, tagk) {
|
||||||
|
if(tagks.indexOf(tagk) === -1) {
|
||||||
|
tagks.push(tagk);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return tagks;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
OpenTSDBDatasource.prototype.testDatasource = function() {
|
OpenTSDBDatasource.prototype.testDatasource = function() {
|
||||||
return this.performSuggestQuery('cpu', 'metrics').then(function () {
|
return this.performSuggestQuery('cpu', 'metrics').then(function () {
|
||||||
return { status: "success", message: "Data source is working", title: "Success" };
|
return { status: "success", message: "Data source is working", title: "Success" };
|
||||||
|
@ -50,13 +50,13 @@ function (angular, _, kbn) {
|
|||||||
|
|
||||||
$scope.suggestTagKeys = function(query, callback) {
|
$scope.suggestTagKeys = function(query, callback) {
|
||||||
$scope.datasource
|
$scope.datasource
|
||||||
.performSuggestQuery(query, 'tagk')
|
.performMetricKeyLookup($scope.target.metric)
|
||||||
.then(callback);
|
.then(callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.suggestTagValues = function(query, callback) {
|
$scope.suggestTagValues = function(query, callback) {
|
||||||
$scope.datasource
|
$scope.datasource
|
||||||
.performSuggestQuery(query, 'tagv')
|
.performMetricKeyValueLookup($scope.target.metric, $scope.target.currentTagKey)
|
||||||
.then(callback);
|
.then(callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user