mirror of
https://github.com/grafana/grafana.git
synced 2025-01-10 08:03:58 -06:00
updated
This commit is contained in:
parent
a8e3f731b7
commit
1adb7b286c
@ -89,6 +89,10 @@ func getFrontendSettingsMap(c *middleware.Context) (map[string]interface{}, erro
|
||||
dsMap["index"] = ds.Database
|
||||
}
|
||||
|
||||
if ds.Type == m.DS_INFLUXDB {
|
||||
dsMap["database"] = ds.Database
|
||||
}
|
||||
|
||||
if ds.Type == m.DS_PROMETHEUS {
|
||||
// add unproxied server URL for link to Prometheus web UI
|
||||
dsMap["directUrl"] = ds.Url
|
||||
|
@ -179,7 +179,7 @@ export default class InfluxQuery {
|
||||
|
||||
var measurement = target.measurement;
|
||||
if (!measurement.match('^/.*/') && !measurement.match(/^merge\(.*\)/)) {
|
||||
measurement = '"' + measurement+ '"';
|
||||
measurement = '"' + measurement+ '"';
|
||||
}
|
||||
|
||||
query += ' FROM ' + measurement + ' WHERE ';
|
||||
|
@ -4,17 +4,9 @@ define([
|
||||
function (_) {
|
||||
'use strict';
|
||||
|
||||
function InfluxQueryBuilder(target, queryModel) {
|
||||
function InfluxQueryBuilder(target, database) {
|
||||
this.target = target;
|
||||
this.model = queryModel;
|
||||
|
||||
if (target.groupByTags) {
|
||||
target.groupBy = [{type: 'time', interval: 'auto'}];
|
||||
for (var i in target.groupByTags) {
|
||||
target.groupBy.push({type: 'tag', key: target.groupByTags[i]});
|
||||
}
|
||||
delete target.groupByTags;
|
||||
}
|
||||
this.database = database;
|
||||
}
|
||||
|
||||
function renderTagCondition (tag, index) {
|
||||
@ -63,7 +55,7 @@ function (_) {
|
||||
query = 'SHOW FIELD KEYS FROM "' + this.target.measurement + '"';
|
||||
return query;
|
||||
} else if (type === 'RETENTION POLICIES') {
|
||||
query = 'SHOW RETENTION POLICIES';
|
||||
query = 'SHOW RETENTION POLICIES on "' + this.database + '"';
|
||||
return query;
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ function (angular, _, InfluxQueryBuilder, InfluxQuery, queryPart) {
|
||||
|
||||
$scope.target = $scope.target;
|
||||
$scope.queryModel = new InfluxQuery($scope.target);
|
||||
$scope.queryBuilder = new InfluxQueryBuilder($scope.target);
|
||||
$scope.queryBuilder = new InfluxQueryBuilder($scope.target, $scope.datasource.database);
|
||||
$scope.groupBySegment = uiSegmentSrv.newPlusButton();
|
||||
$scope.resultFormats = [
|
||||
{text: 'Time series', value: 'time_series'},
|
||||
|
@ -71,9 +71,9 @@ describe('InfluxQueryBuilder', function() {
|
||||
});
|
||||
|
||||
it('should build show retention policies query', function() {
|
||||
var builder = new InfluxQueryBuilder({measurement: 'cpu', tags: []});
|
||||
var builder = new InfluxQueryBuilder({measurement: 'cpu', tags: []}, 'site');
|
||||
var query = builder.buildExploreQuery('RETENTION POLICIES');
|
||||
expect(query).to.be('SHOW RETENTION POLICIES');
|
||||
expect(query).to.be('SHOW RETENTION POLICIES on "site"');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user