mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Merge branch 'master' of https://github.com/omki2005/grafana into omki2005-master
This commit is contained in:
commit
4b76c6d652
@ -42,13 +42,16 @@ function (_) {
|
|||||||
p.buildExploreQuery = function(type, withKey, withMeasurementFilter) {
|
p.buildExploreQuery = function(type, withKey, withMeasurementFilter) {
|
||||||
var query;
|
var query;
|
||||||
var measurement;
|
var measurement;
|
||||||
|
var policy;
|
||||||
|
|
||||||
if (type === 'TAG_KEYS') {
|
if (type === 'TAG_KEYS') {
|
||||||
query = 'SHOW TAG KEYS';
|
query = 'SHOW TAG KEYS';
|
||||||
measurement = this.target.measurement;
|
measurement = this.target.measurement;
|
||||||
|
policy = this.target.policy;
|
||||||
} else if (type === 'TAG_VALUES') {
|
} else if (type === 'TAG_VALUES') {
|
||||||
query = 'SHOW TAG VALUES';
|
query = 'SHOW TAG VALUES';
|
||||||
measurement = this.target.measurement;
|
measurement = this.target.measurement;
|
||||||
|
policy = this.target.policy;
|
||||||
} else if (type === 'MEASUREMENTS') {
|
} else if (type === 'MEASUREMENTS') {
|
||||||
query = 'SHOW MEASUREMENTS';
|
query = 'SHOW MEASUREMENTS';
|
||||||
if (withMeasurementFilter)
|
if (withMeasurementFilter)
|
||||||
@ -56,11 +59,18 @@ function (_) {
|
|||||||
query += ' WITH MEASUREMENT =~ /' + withMeasurementFilter +'/';
|
query += ' WITH MEASUREMENT =~ /' + withMeasurementFilter +'/';
|
||||||
}
|
}
|
||||||
} else if (type === 'FIELDS') {
|
} else if (type === 'FIELDS') {
|
||||||
if (!this.target.measurement.match('^/.*/')) {
|
measurement = this.target.measurement;
|
||||||
return 'SHOW FIELD KEYS FROM "' + this.target.measurement + '"';
|
policy = this.target.policy;
|
||||||
} else {
|
if (!measurement.match('^/.*/')) {
|
||||||
return 'SHOW FIELD KEYS FROM ' + this.target.measurement;
|
measurement = '"' + measurement + '"';
|
||||||
|
if (policy) {
|
||||||
|
if (!policy.match('^/.*/')) {
|
||||||
|
policy = '"' + policy + '"';
|
||||||
|
}
|
||||||
|
measurement = policy + '.' + measurement;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return 'SHOW FIELD KEYS FROM ' + measurement;
|
||||||
} else if (type === 'RETENTION POLICIES') {
|
} else if (type === 'RETENTION POLICIES') {
|
||||||
query = 'SHOW RETENTION POLICIES on "' + this.database + '"';
|
query = 'SHOW RETENTION POLICIES on "' + this.database + '"';
|
||||||
return query;
|
return query;
|
||||||
@ -70,6 +80,12 @@ function (_) {
|
|||||||
if (!measurement.match('^/.*/') && !measurement.match(/^merge\(.*\)/)) {
|
if (!measurement.match('^/.*/') && !measurement.match(/^merge\(.*\)/)) {
|
||||||
measurement = '"' + measurement+ '"';
|
measurement = '"' + measurement+ '"';
|
||||||
}
|
}
|
||||||
|
if (policy) {
|
||||||
|
if (!policy.match('^/.*/') && !policy.match(/^merge\(.*\)/)) {
|
||||||
|
policy = '"' + policy + '"';
|
||||||
|
}
|
||||||
|
measurement = policy + '.' + measurement;
|
||||||
|
}
|
||||||
query += ' FROM ' + measurement;
|
query += ' FROM ' + measurement;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,6 +73,17 @@ describe('InfluxQueryBuilder', function() {
|
|||||||
expect(query).to.be('SHOW TAG VALUES FROM "cpu" WITH KEY = "app" WHERE "host" = \'server1\'');
|
expect(query).to.be('SHOW TAG VALUES FROM "cpu" WITH KEY = "app" WHERE "host" = \'server1\'');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it ('should select from policy correctly if policy is specified', function() {
|
||||||
|
var builder = new InfluxQueryBuilder({
|
||||||
|
measurement: 'cpu',
|
||||||
|
policy: 'one_week',
|
||||||
|
tags: [{key: 'app', value: 'email'},
|
||||||
|
{key: 'host', value: 'server1'}]
|
||||||
|
});
|
||||||
|
var query = builder.buildExploreQuery('TAG_VALUES', 'app');
|
||||||
|
expect(query).to.be('SHOW TAG VALUES FROM "one_week"."cpu" WITH KEY = "app" WHERE "host" = \'server1\'');
|
||||||
|
});
|
||||||
|
|
||||||
it('should switch to regex operator in tag condition', function() {
|
it('should switch to regex operator in tag condition', function() {
|
||||||
var builder = new InfluxQueryBuilder({
|
var builder = new InfluxQueryBuilder({
|
||||||
measurement: 'cpu',
|
measurement: 'cpu',
|
||||||
|
Loading…
Reference in New Issue
Block a user