add min interval to postgres datasource

This commit is contained in:
Sven Klemm
2018-08-25 18:14:39 +02:00
parent ea110b5931
commit 21e7b0b92d
3 changed files with 19 additions and 2 deletions

View File

@ -38,6 +38,18 @@
</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>
<div class="gf-form-group">

View File

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

View File

@ -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) {