mirror of
https://github.com/grafana/grafana.git
synced 2025-08-06 20:59:35 +08:00
send timerange with metricFindQuery
This commit is contained in:
@ -8,7 +8,7 @@ export class PostgresDatasource {
|
||||
responseParser: ResponseParser;
|
||||
|
||||
/** @ngInject **/
|
||||
constructor(instanceSettings, private backendSrv, private $q, private templateSrv) {
|
||||
constructor(instanceSettings, private backendSrv, private $q, private templateSrv, private timeSrv) {
|
||||
this.name = instanceSettings.name;
|
||||
this.id = instanceSettings.id;
|
||||
this.responseParser = new ResponseParser(this.$q);
|
||||
@ -106,17 +106,13 @@ export class PostgresDatasource {
|
||||
format: 'table',
|
||||
};
|
||||
|
||||
var data = {
|
||||
let range = this.timeSrv.timeRange();
|
||||
let data = {
|
||||
queries: [interpolatedQuery],
|
||||
from: range.from.valueOf().toString(),
|
||||
to: range.to.valueOf().toString(),
|
||||
};
|
||||
|
||||
if (optionalOptions && optionalOptions.range && optionalOptions.range.from) {
|
||||
data['from'] = optionalOptions.range.from.valueOf().toString();
|
||||
}
|
||||
if (optionalOptions && optionalOptions.range && optionalOptions.range.to) {
|
||||
data['to'] = optionalOptions.range.to.valueOf().toString();
|
||||
}
|
||||
|
||||
return this.backendSrv
|
||||
.datasourceRequest({
|
||||
url: '/api/tsdb/query',
|
||||
|
@ -46,6 +46,7 @@ export class PostgresQueryBuilder {
|
||||
buildValueQuery(column: string) {
|
||||
var query = 'SELECT DISTINCT quote_literal(' + column + ')';
|
||||
query += ' FROM ' + this.target.schema + '.' + this.target.table;
|
||||
query += ' WHERE $__timeFilter(' + this.target.timeColumn + ')';
|
||||
query += ' ORDER BY 1 LIMIT 100';
|
||||
return query;
|
||||
}
|
||||
|
Reference in New Issue
Block a user