diff --git a/public/app/features/dashboard/dashgrid/DataPanel.tsx b/public/app/features/dashboard/dashgrid/DataPanel.tsx index 7a28d54f5b8..fa52da377ad 100644 --- a/public/app/features/dashboard/dashgrid/DataPanel.tsx +++ b/public/app/features/dashboard/dashgrid/DataPanel.tsx @@ -132,10 +132,16 @@ export class DataPanel extends Component { try { const ds = await this.dataSourceSrv.get(datasource, scopedVars); - // TODO interpolate variables const minInterval = this.props.minInterval || ds.interval; const intervalRes = kbn.calculateInterval(timeRange, widthPixels, minInterval); + // make shallow copy of scoped vars, + // and add built in variables interval and interval_ms + const scopedVarsWithInterval = Object.assign({}, scopedVars, { + __interval: { text: intervalRes.interval, value: intervalRes.interval }, + __interval_ms: { text: intervalRes.intervalMs.toString(), value: intervalRes.intervalMs }, + }); + const queryOptions: DataQueryOptions = { timezone: 'browser', panelId: panelId, @@ -146,7 +152,7 @@ export class DataPanel extends Component { intervalMs: intervalRes.intervalMs, targets: queries, maxDataPoints: maxDataPoints || widthPixels, - scopedVars: scopedVars || {}, + scopedVars: scopedVarsWithInterval, cacheTimeout: null, };