Skip to content
This repository has been archived by the owner on Dec 11, 2020. It is now read-only.

Commit

Permalink
Merge pull request #26 from zarbis/variables-time-range
Browse files Browse the repository at this point in the history
Respect `$range` in variable evaluation requests
  • Loading branch information
srclosson committed Oct 10, 2019
2 parents d1dd958 + b73f90a commit 6027c93
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/datasource.ts
Expand Up @@ -101,10 +101,18 @@ export default class InfluxDatasource {

metricFindQuery(query: string, options?: any) {
const interpreted = expandMacros(query);
let rangeRaw = { to: 'now', from: 'now - 1h' };
if (options && typeof options === 'object') {
if (options.range && options.range.raw) {
rangeRaw = options.range.raw;
} else if (options.variable && options.variable.timeSrv && options.variable.timeSrv.time) {
rangeRaw = options.variable.timeSrv.time;
}
}

// Use normal querier in silent mode
const queryOptions = {
rangeRaw: { to: 'now', from: 'now - 1h' },
rangeRaw,
scopedVars: {},
...options,
silent: true,
Expand Down

0 comments on commit 6027c93

Please sign in to comment.