This commit is contained in:
Torkel Ödegaard 2016-01-18 07:28:01 +01:00
parent a8e3f731b7
commit 1adb7b286c
5 changed files with 11 additions and 15 deletions

View File

@ -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

View File

@ -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 ';

View File

@ -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;
}

View File

@ -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'},

View File

@ -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"');
});
});
});