Commit acb45867 by Marcus Efraimsson Committed by GitHub

Merge pull request #14179 from mattiarossi/master

Add support for offset in date histogram aggregation
parents d16b3488 ce74b1dd
......@@ -240,6 +240,7 @@ type DateHistogramAgg struct {
Missing *string `json:"missing,omitempty"`
ExtendedBounds *ExtendedBounds `json:"extended_bounds"`
Format string `json:"format"`
Offset string `json:"offset,omitempty"`
}
// FiltersAggregation represents a filters aggregation
......
......@@ -134,6 +134,10 @@ func addDateHistogramAgg(aggBuilder es.AggBuilder, bucketAgg *BucketAgg, timeFro
a.Interval = "$__interval"
}
if offset, err := bucketAgg.Settings.Get("offset").String(); err == nil {
a.Offset = offset
}
if missing, err := bucketAgg.Settings.Get("missing").String(); err == nil {
a.Missing = &missing
}
......
......@@ -70,6 +70,16 @@
</label>
<input class="gf-form-input max-width-12" type="number" ng-model="agg.settings.trimEdges" ng-change="onChangeInternal()">
</div>
<div class="gf-form offset-width-7">
<label class="gf-form-label width-10">
Offset
<info-popover mode="right-normal">
Change the start value of each bucket by the specified positive (+) or negative offset (-) duration, such as 1h for an hour, or 1d for a day
</info-popover>
</label>
<input class="gf-form-input max-width-12" type="text" ng-model="agg.settings.offset" ng-change="onChangeInternal()">
</div>
</div>
<div ng-if="agg.type === 'histogram'">
......
......@@ -72,6 +72,10 @@ export class ElasticQueryBuilder {
esAgg.extended_bounds = { min: '$timeFrom', max: '$timeTo' };
esAgg.format = 'epoch_millis';
if (settings.offset !== '') {
esAgg.offset = settings.offset;
}
if (esAgg.interval === 'auto') {
esAgg.interval = '$__interval';
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment