mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Fix to issue 2524 by limiting number of returned measurements for display. (#8092)
This commit is contained in:
parent
92d723d6f5
commit
c485fed744
@ -91,7 +91,13 @@ function (_) {
|
|||||||
query += ' WHERE ' + whereConditions.join(' ');
|
query += ' WHERE ' + whereConditions.join(' ');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (type === 'MEASUREMENTS')
|
||||||
|
{
|
||||||
|
query += ' LIMIT 100';
|
||||||
|
//Solve issue #2524 by limiting the number of measurements returned
|
||||||
|
//LIMIT must be after WITH MEASUREMENT and WHERE clauses
|
||||||
|
//This also could be used for TAG KEYS and TAG VALUES, if desired
|
||||||
|
}
|
||||||
return query;
|
return query;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -34,31 +34,31 @@ describe('InfluxQueryBuilder', function() {
|
|||||||
it('should have no conditions in measurement query for query with no tags', function() {
|
it('should have no conditions in measurement query for query with no tags', function() {
|
||||||
var builder = new InfluxQueryBuilder({ measurement: '', tags: [] });
|
var builder = new InfluxQueryBuilder({ measurement: '', tags: [] });
|
||||||
var query = builder.buildExploreQuery('MEASUREMENTS');
|
var query = builder.buildExploreQuery('MEASUREMENTS');
|
||||||
expect(query).to.be('SHOW MEASUREMENTS');
|
expect(query).to.be('SHOW MEASUREMENTS LIMIT 100');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have no conditions in measurement query for query with no tags and empty query', function() {
|
it('should have no conditions in measurement query for query with no tags and empty query', function() {
|
||||||
var builder = new InfluxQueryBuilder({ measurement: '', tags: [] });
|
var builder = new InfluxQueryBuilder({ measurement: '', tags: [] });
|
||||||
var query = builder.buildExploreQuery('MEASUREMENTS', undefined, '');
|
var query = builder.buildExploreQuery('MEASUREMENTS', undefined, '');
|
||||||
expect(query).to.be('SHOW MEASUREMENTS');
|
expect(query).to.be('SHOW MEASUREMENTS LIMIT 100');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have WITH MEASUREMENT in measurement query for non-empty query with no tags', function() {
|
it('should have WITH MEASUREMENT in measurement query for non-empty query with no tags', function() {
|
||||||
var builder = new InfluxQueryBuilder({ measurement: '', tags: [] });
|
var builder = new InfluxQueryBuilder({ measurement: '', tags: [] });
|
||||||
var query = builder.buildExploreQuery('MEASUREMENTS', undefined, 'something');
|
var query = builder.buildExploreQuery('MEASUREMENTS', undefined, 'something');
|
||||||
expect(query).to.be('SHOW MEASUREMENTS WITH MEASUREMENT =~ /something/');
|
expect(query).to.be('SHOW MEASUREMENTS WITH MEASUREMENT =~ /something/ LIMIT 100');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have WITH MEASUREMENT WHERE in measurement query for non-empty query with tags', function() {
|
it('should have WITH MEASUREMENT WHERE in measurement query for non-empty query with tags', function() {
|
||||||
var builder = new InfluxQueryBuilder({ measurement: '', tags: [{key: 'app', value: 'email'}] });
|
var builder = new InfluxQueryBuilder({ measurement: '', tags: [{key: 'app', value: 'email'}] });
|
||||||
var query = builder.buildExploreQuery('MEASUREMENTS', undefined, 'something');
|
var query = builder.buildExploreQuery('MEASUREMENTS', undefined, 'something');
|
||||||
expect(query).to.be("SHOW MEASUREMENTS WITH MEASUREMENT =~ /something/ WHERE \"app\" = 'email'");
|
expect(query).to.be("SHOW MEASUREMENTS WITH MEASUREMENT =~ /something/ WHERE \"app\" = 'email' LIMIT 100");
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have where condition in measurement query for query with tags', function() {
|
it('should have where condition in measurement query for query with tags', function() {
|
||||||
var builder = new InfluxQueryBuilder({measurement: '', tags: [{key: 'app', value: 'email'}]});
|
var builder = new InfluxQueryBuilder({measurement: '', tags: [{key: 'app', value: 'email'}]});
|
||||||
var query = builder.buildExploreQuery('MEASUREMENTS');
|
var query = builder.buildExploreQuery('MEASUREMENTS');
|
||||||
expect(query).to.be("SHOW MEASUREMENTS WHERE \"app\" = 'email'");
|
expect(query).to.be("SHOW MEASUREMENTS WHERE \"app\" = 'email' LIMIT 100");
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have where tag name IN filter in tag values query for query with one tag', function() {
|
it('should have where tag name IN filter in tag values query for query with one tag', function() {
|
||||||
|
Loading…
Reference in New Issue
Block a user