mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -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
|
dsMap["index"] = ds.Database
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ds.Type == m.DS_INFLUXDB {
|
||||||
|
dsMap["database"] = ds.Database
|
||||||
|
}
|
||||||
|
|
||||||
if ds.Type == m.DS_PROMETHEUS {
|
if ds.Type == m.DS_PROMETHEUS {
|
||||||
// add unproxied server URL for link to Prometheus web UI
|
// add unproxied server URL for link to Prometheus web UI
|
||||||
dsMap["directUrl"] = ds.Url
|
dsMap["directUrl"] = ds.Url
|
||||||
|
@ -179,7 +179,7 @@ export default class InfluxQuery {
|
|||||||
|
|
||||||
var measurement = target.measurement;
|
var measurement = target.measurement;
|
||||||
if (!measurement.match('^/.*/') && !measurement.match(/^merge\(.*\)/)) {
|
if (!measurement.match('^/.*/') && !measurement.match(/^merge\(.*\)/)) {
|
||||||
measurement = '"' + measurement+ '"';
|
measurement = '"' + measurement+ '"';
|
||||||
}
|
}
|
||||||
|
|
||||||
query += ' FROM ' + measurement + ' WHERE ';
|
query += ' FROM ' + measurement + ' WHERE ';
|
||||||
|
@ -4,17 +4,9 @@ define([
|
|||||||
function (_) {
|
function (_) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
function InfluxQueryBuilder(target, queryModel) {
|
function InfluxQueryBuilder(target, database) {
|
||||||
this.target = target;
|
this.target = target;
|
||||||
this.model = queryModel;
|
this.database = database;
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderTagCondition (tag, index) {
|
function renderTagCondition (tag, index) {
|
||||||
@ -63,7 +55,7 @@ function (_) {
|
|||||||
query = 'SHOW FIELD KEYS FROM "' + this.target.measurement + '"';
|
query = 'SHOW FIELD KEYS FROM "' + this.target.measurement + '"';
|
||||||
return query;
|
return query;
|
||||||
} else if (type === 'RETENTION POLICIES') {
|
} else if (type === 'RETENTION POLICIES') {
|
||||||
query = 'SHOW RETENTION POLICIES';
|
query = 'SHOW RETENTION POLICIES on "' + this.database + '"';
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ function (angular, _, InfluxQueryBuilder, InfluxQuery, queryPart) {
|
|||||||
|
|
||||||
$scope.target = $scope.target;
|
$scope.target = $scope.target;
|
||||||
$scope.queryModel = new InfluxQuery($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.groupBySegment = uiSegmentSrv.newPlusButton();
|
||||||
$scope.resultFormats = [
|
$scope.resultFormats = [
|
||||||
{text: 'Time series', value: 'time_series'},
|
{text: 'Time series', value: 'time_series'},
|
||||||
|
@ -71,9 +71,9 @@ describe('InfluxQueryBuilder', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should build show retention policies query', 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');
|
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