From 41eb0ba52e95eb6040849fa14fec6ab44d82774d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Kreileder?= Date: Tue, 12 Jun 2018 18:32:59 +0200 Subject: [PATCH] Add support for InfluxDB's time zone clause --- public/app/plugins/datasource/influxdb/influx_query.ts | 4 ++++ .../datasource/influxdb/partials/query.editor.html | 10 ++++++++++ public/app/plugins/datasource/influxdb/query_ctrl.ts | 7 +++++++ 3 files changed, 21 insertions(+) diff --git a/public/app/plugins/datasource/influxdb/influx_query.ts b/public/app/plugins/datasource/influxdb/influx_query.ts index 60eac1d3f2b..3ee9d703c54 100644 --- a/public/app/plugins/datasource/influxdb/influx_query.ts +++ b/public/app/plugins/datasource/influxdb/influx_query.ts @@ -256,6 +256,10 @@ export default class InfluxQuery { query += ' SLIMIT ' + target.slimit; } + if (target.tz) { + query += " tz('" + target.tz + "')"; + } + return query; } diff --git a/public/app/plugins/datasource/influxdb/partials/query.editor.html b/public/app/plugins/datasource/influxdb/partials/query.editor.html index e1c35d77115..658cf18daee 100644 --- a/public/app/plugins/datasource/influxdb/partials/query.editor.html +++ b/public/app/plugins/datasource/influxdb/partials/query.editor.html @@ -119,6 +119,16 @@ +
+
+ + +
+
+
+
+
+
diff --git a/public/app/plugins/datasource/influxdb/query_ctrl.ts b/public/app/plugins/datasource/influxdb/query_ctrl.ts index f531fe6c4d9..57460ec4d2a 100644 --- a/public/app/plugins/datasource/influxdb/query_ctrl.ts +++ b/public/app/plugins/datasource/influxdb/query_ctrl.ts @@ -100,6 +100,9 @@ export class InfluxQueryCtrl extends QueryCtrl { if (!this.target.slimit) { options.push(this.uiSegmentSrv.newSegment({ value: 'SLIMIT' })); } + if (!this.target.tz) { + options.push(this.uiSegmentSrv.newSegment({ value: 'tz' })); + } if (this.target.orderByTime === 'ASC') { options.push(this.uiSegmentSrv.newSegment({ value: 'ORDER BY time DESC' })); } @@ -124,6 +127,10 @@ export class InfluxQueryCtrl extends QueryCtrl { this.target.slimit = 10; break; } + case 'tz': { + this.target.tz = 'UTC'; + break; + } case 'ORDER BY time DESC': { this.target.orderByTime = 'DESC'; break;