mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Minor work on InfluxDB 0.9 query editor, #1525, hit a roadblock with the new InfluxDB query language, does not support tag and tag values discovery queries with filters, not sure if I need to move to SHOW SERIES style queries
This commit is contained in:
parent
6fd37779b8
commit
7a41ecb63f
public
@ -49,8 +49,8 @@ function (angular, _) {
|
||||
|
||||
$scope.groupBySegments.push(MetricSegment.newPlusButton());
|
||||
|
||||
$scope.removeTagFilterSegment = new MetricSegment({fake: true, value: 'remove tag filter'});
|
||||
$scope.removeGroupBySegment = new MetricSegment({fake: true, value: 'remove group by'});
|
||||
$scope.removeTagFilterSegment = new MetricSegment({fake: true, value: '-- remove tag filter --'});
|
||||
$scope.removeGroupBySegment = new MetricSegment({fake: true, value: '-- remove group by --'});
|
||||
};
|
||||
|
||||
$scope.fixTagSegments = function() {
|
||||
@ -129,11 +129,21 @@ function (angular, _) {
|
||||
return segments;
|
||||
};
|
||||
|
||||
$scope.buildTagKeysQuery = function(target) {
|
||||
var query = 'SHOW TAG KEYS';
|
||||
|
||||
if (target.measurement) {
|
||||
query += ' FROM "' + target.measurement + '"';
|
||||
}
|
||||
|
||||
return query;
|
||||
};
|
||||
|
||||
$scope.getTagsOrValues = function(segment, index) {
|
||||
var query, queryType;
|
||||
if (segment.type === 'key' || segment.type === 'plus-button') {
|
||||
queryType = 'TAG_KEYS';
|
||||
query = 'SHOW TAG KEYS FROM "' + $scope.target.measurement + '"';
|
||||
query = $scope.buildTagKeysQuery($scope.target, segment);
|
||||
} else if (segment.type === 'value') {
|
||||
queryType = 'TAG_VALUES';
|
||||
query = 'SHOW TAG VALUES FROM "' + $scope.target.measurement + '" WITH KEY = ' + $scope.tagSegments[index-2].value;
|
||||
@ -149,7 +159,7 @@ function (angular, _) {
|
||||
.then($scope.addTemplateVariableSegments)
|
||||
.then(function(results) {
|
||||
if (queryType === 'TAG_KEYS' && segment.type === 'key') {
|
||||
results.push(angular.copy($scope.removeTagFilterSegment));
|
||||
results.splice(0, 0, angular.copy($scope.removeTagFilterSegment));
|
||||
}
|
||||
return results;
|
||||
})
|
||||
@ -164,7 +174,7 @@ function (angular, _) {
|
||||
.then($scope.addTemplateVariableSegments)
|
||||
.then(function(results) {
|
||||
if (segment.type !== 'plus-button') {
|
||||
results.push(angular.copy($scope.removeGroupBySegment));
|
||||
results.splice(0, 0, angular.copy($scope.removeGroupBySegment));
|
||||
}
|
||||
return results;
|
||||
})
|
||||
|
@ -198,5 +198,23 @@ define([
|
||||
});
|
||||
});
|
||||
|
||||
describe('when building tag keys query', function() {
|
||||
|
||||
describe('given picked measurement', function() {
|
||||
it('build query with measurement filter', function() {
|
||||
var query = ctx.scope.buildTagKeysQuery({ measurement: 'cpu', tags: [] }, {type: 'key'});
|
||||
expect(query).to.be('SHOW TAG KEYS FROM "cpu"');
|
||||
});
|
||||
});
|
||||
|
||||
describe('given no picked measurement', function() {
|
||||
it('build query without filter', function() {
|
||||
var query = ctx.scope.buildTagKeysQuery({ measurement: '', tags: [] }, {type: 'key'});
|
||||
expect(query).to.be('SHOW TAG KEYS');
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user