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

Commit 6027c93

Browse files
authored
Merge pull request #26 from zarbis/variables-time-range
Respect `$range` in variable evaluation requests
2 parents d1dd958 + b73f90a commit 6027c93

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/datasource.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,18 @@ export default class InfluxDatasource {
101101

102102
metricFindQuery(query: string, options?: any) {
103103
const interpreted = expandMacros(query);
104+
let rangeRaw = { to: 'now', from: 'now - 1h' };
105+
if (options && typeof options === 'object') {
106+
if (options.range && options.range.raw) {
107+
rangeRaw = options.range.raw;
108+
} else if (options.variable && options.variable.timeSrv && options.variable.timeSrv.time) {
109+
rangeRaw = options.variable.timeSrv.time;
110+
}
111+
}
104112

105113
// Use normal querier in silent mode
106114
const queryOptions = {
107-
rangeRaw: { to: 'now', from: 'now - 1h' },
115+
rangeRaw,
108116
scopedVars: {},
109117
...options,
110118
silent: true,

0 commit comments

Comments
 (0)