Browse Source

add min interval to postgres datasource

Sven Klemm 7 năm trước cách đây
mục cha
commit
21e7b0b92d

+ 12 - 0
public/app/plugins/datasource/postgres/partials/config.html

@@ -38,6 +38,18 @@
 	</div>
 	</div>
 </div>
 </div>
 
 
+<div class="gf-form-group">
+	<div class="gf-form-inline">
+		<div class="gf-form">
+			<span class="gf-form-label">Min time interval</span>
+			<input type="text" class="gf-form-input width-6" ng-model="ctrl.current.jsonData.timeInterval" spellcheck='false' placeholder="10s"></input>
+			<info-popover mode="right-absolute">
+				A lower limit for the auto group by time interval. Recommended to be set to write frequency,
+				for example <code>1m</code> if your data is written every minute.
+			</info-popover>
+		</div>
+	</div>
+</div>
 <h3 class="page-heading">PostgreSQL details</h3>
 <h3 class="page-heading">PostgreSQL details</h3>
 
 
 <div class="gf-form-group">
 <div class="gf-form-group">

+ 6 - 1
public/app/plugins/datasource/postgres/plugin.json

@@ -18,5 +18,10 @@
 
 
   "alerting": true,
   "alerting": true,
   "annotations": true,
   "annotations": true,
-  "metrics": true
+  "metrics": true,
+
+  "queryOptions": {
+    "minInterval": true
+  }
+
 }
 }

+ 1 - 1
public/app/plugins/datasource/postgres/query_ctrl.ts

@@ -317,7 +317,7 @@ export class PostgresQueryCtrl extends QueryCtrl {
       case 'aggregate':
       case 'aggregate':
         // add group by if no group by yet
         // add group by if no group by yet
         if (this.target.group.length === 0) {
         if (this.target.group.length === 0) {
-          this.addGroup('time', '1m');
+          this.addGroup('time', '$__interval');
         }
         }
         let aggIndex = this.findAggregateIndex(selectParts);
         let aggIndex = this.findAggregateIndex(selectParts);
         if (aggIndex !== -1) {
         if (aggIndex !== -1) {