mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
make sure graphite takes dashboard timezone into consideration
This commit is contained in:
parent
8f6ccce16f
commit
37a73b6b35
@ -31,8 +31,8 @@ export function GraphiteDatasource(this: any, instanceSettings, $q, backendSrv,
|
|||||||
|
|
||||||
this.query = function(options) {
|
this.query = function(options) {
|
||||||
const graphOptions = {
|
const graphOptions = {
|
||||||
from: this.translateTime(options.rangeRaw.from, false),
|
from: this.translateTime(options.rangeRaw.from, false, options.timezone),
|
||||||
until: this.translateTime(options.rangeRaw.to, true),
|
until: this.translateTime(options.rangeRaw.to, true, options.timezone),
|
||||||
targets: options.targets,
|
targets: options.targets,
|
||||||
format: options.format,
|
format: options.format,
|
||||||
cacheTimeout: options.cacheTimeout || this.cacheTimeout,
|
cacheTimeout: options.cacheTimeout || this.cacheTimeout,
|
||||||
@ -165,9 +165,9 @@ export function GraphiteDatasource(this: any, instanceSettings, $q, backendSrv,
|
|||||||
method: 'GET',
|
method: 'GET',
|
||||||
url:
|
url:
|
||||||
'/events/get_data?from=' +
|
'/events/get_data?from=' +
|
||||||
this.translateTime(options.range.from, false) +
|
this.translateTime(options.range.from, false, options.timezone) +
|
||||||
'&until=' +
|
'&until=' +
|
||||||
this.translateTime(options.range.to, true) +
|
this.translateTime(options.range.to, true, options.timezone) +
|
||||||
tags,
|
tags,
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@ -179,7 +179,7 @@ export function GraphiteDatasource(this: any, instanceSettings, $q, backendSrv,
|
|||||||
return templateSrv.variableExists(target.target);
|
return templateSrv.variableExists(target.target);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.translateTime = (date, roundUp) => {
|
this.translateTime = (date, roundUp, timezone) => {
|
||||||
if (_.isString(date)) {
|
if (_.isString(date)) {
|
||||||
if (date === 'now') {
|
if (date === 'now') {
|
||||||
return 'now';
|
return 'now';
|
||||||
@ -189,7 +189,7 @@ export function GraphiteDatasource(this: any, instanceSettings, $q, backendSrv,
|
|||||||
date = date.replace('M', 'mon');
|
date = date.replace('M', 'mon');
|
||||||
return date;
|
return date;
|
||||||
}
|
}
|
||||||
date = dateMath.parse(date, roundUp);
|
date = dateMath.parse(date, roundUp, timezone);
|
||||||
}
|
}
|
||||||
|
|
||||||
// graphite' s from filter is exclusive
|
// graphite' s from filter is exclusive
|
||||||
@ -255,8 +255,8 @@ export function GraphiteDatasource(this: any, instanceSettings, $q, backendSrv,
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (options.range) {
|
if (options.range) {
|
||||||
httpOptions.params.from = this.translateTime(options.range.from, false);
|
httpOptions.params.from = this.translateTime(options.range.from, false, options.timezone);
|
||||||
httpOptions.params.until = this.translateTime(options.range.to, true);
|
httpOptions.params.until = this.translateTime(options.range.to, true, options.timezone);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.doGraphiteRequest(httpOptions).then(results => {
|
return this.doGraphiteRequest(httpOptions).then(results => {
|
||||||
@ -280,8 +280,8 @@ export function GraphiteDatasource(this: any, instanceSettings, $q, backendSrv,
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (options.range) {
|
if (options.range) {
|
||||||
httpOptions.params.from = this.translateTime(options.range.from, false);
|
httpOptions.params.from = this.translateTime(options.range.from, false, options.timezone);
|
||||||
httpOptions.params.until = this.translateTime(options.range.to, true);
|
httpOptions.params.until = this.translateTime(options.range.to, true, options.timezone);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.doGraphiteRequest(httpOptions).then(results => {
|
return this.doGraphiteRequest(httpOptions).then(results => {
|
||||||
@ -305,8 +305,8 @@ export function GraphiteDatasource(this: any, instanceSettings, $q, backendSrv,
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (options.range) {
|
if (options.range) {
|
||||||
httpOptions.params.from = this.translateTime(options.range.from, false);
|
httpOptions.params.from = this.translateTime(options.range.from, false, options.timezone);
|
||||||
httpOptions.params.until = this.translateTime(options.range.to, true);
|
httpOptions.params.until = this.translateTime(options.range.to, true, options.timezone);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.doGraphiteRequest(httpOptions).then(results => {
|
return this.doGraphiteRequest(httpOptions).then(results => {
|
||||||
@ -343,8 +343,8 @@ export function GraphiteDatasource(this: any, instanceSettings, $q, backendSrv,
|
|||||||
httpOptions.params.limit = options.limit;
|
httpOptions.params.limit = options.limit;
|
||||||
}
|
}
|
||||||
if (options.range) {
|
if (options.range) {
|
||||||
httpOptions.params.from = this.translateTime(options.range.from, false);
|
httpOptions.params.from = this.translateTime(options.range.from, false, options.timezone);
|
||||||
httpOptions.params.until = this.translateTime(options.range.to, true);
|
httpOptions.params.until = this.translateTime(options.range.to, true, options.timezone);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.doGraphiteRequest(httpOptions).then(results => {
|
return this.doGraphiteRequest(httpOptions).then(results => {
|
||||||
@ -379,8 +379,8 @@ export function GraphiteDatasource(this: any, instanceSettings, $q, backendSrv,
|
|||||||
httpOptions.params.limit = options.limit;
|
httpOptions.params.limit = options.limit;
|
||||||
}
|
}
|
||||||
if (options.range) {
|
if (options.range) {
|
||||||
httpOptions.params.from = this.translateTime(options.range.from, false);
|
httpOptions.params.from = this.translateTime(options.range.from, false, options.timezone);
|
||||||
httpOptions.params.until = this.translateTime(options.range.to, true);
|
httpOptions.params.until = this.translateTime(options.range.to, true, options.timezone);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.doGraphiteRequest(httpOptions).then(results => {
|
return this.doGraphiteRequest(httpOptions).then(results => {
|
||||||
|
Loading…
Reference in New Issue
Block a user