From 21e7b0b92d3534c3059f7fad47364a269276ff1e Mon Sep 17 00:00:00 2001 From: Sven Klemm Date: Sat, 25 Aug 2018 18:14:39 +0200 Subject: [PATCH] add min interval to postgres datasource --- .../plugins/datasource/postgres/partials/config.html | 12 ++++++++++++ public/app/plugins/datasource/postgres/plugin.json | 7 ++++++- public/app/plugins/datasource/postgres/query_ctrl.ts | 2 +- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/public/app/plugins/datasource/postgres/partials/config.html b/public/app/plugins/datasource/postgres/partials/config.html index 40b0f63d254..4cb0cefba9e 100644 --- a/public/app/plugins/datasource/postgres/partials/config.html +++ b/public/app/plugins/datasource/postgres/partials/config.html @@ -38,6 +38,18 @@ +
+
+
+ Min time interval + + + A lower limit for the auto group by time interval. Recommended to be set to write frequency, + for example 1m if your data is written every minute. + +
+
+

PostgreSQL details

diff --git a/public/app/plugins/datasource/postgres/plugin.json b/public/app/plugins/datasource/postgres/plugin.json index af2dbc4468e..f236aa01b06 100644 --- a/public/app/plugins/datasource/postgres/plugin.json +++ b/public/app/plugins/datasource/postgres/plugin.json @@ -18,5 +18,10 @@ "alerting": true, "annotations": true, - "metrics": true + "metrics": true, + + "queryOptions": { + "minInterval": true + } + } diff --git a/public/app/plugins/datasource/postgres/query_ctrl.ts b/public/app/plugins/datasource/postgres/query_ctrl.ts index b6850112446..057086e1cd1 100644 --- a/public/app/plugins/datasource/postgres/query_ctrl.ts +++ b/public/app/plugins/datasource/postgres/query_ctrl.ts @@ -317,7 +317,7 @@ export class PostgresQueryCtrl extends QueryCtrl { case 'aggregate': // add group by if no group by yet if (this.target.group.length === 0) { - this.addGroup('time', '1m'); + this.addGroup('time', '$__interval'); } let aggIndex = this.findAggregateIndex(selectParts); if (aggIndex !== -1) {