mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Merge pull request #14179 from mattiarossi/master
Add support for offset in date histogram aggregation
This commit is contained in:
commit
acb45867f8
@ -240,6 +240,7 @@ type DateHistogramAgg struct {
|
|||||||
Missing *string `json:"missing,omitempty"`
|
Missing *string `json:"missing,omitempty"`
|
||||||
ExtendedBounds *ExtendedBounds `json:"extended_bounds"`
|
ExtendedBounds *ExtendedBounds `json:"extended_bounds"`
|
||||||
Format string `json:"format"`
|
Format string `json:"format"`
|
||||||
|
Offset string `json:"offset,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// FiltersAggregation represents a filters aggregation
|
// FiltersAggregation represents a filters aggregation
|
||||||
|
@ -134,6 +134,10 @@ func addDateHistogramAgg(aggBuilder es.AggBuilder, bucketAgg *BucketAgg, timeFro
|
|||||||
a.Interval = "$__interval"
|
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 {
|
if missing, err := bucketAgg.Settings.Get("missing").String(); err == nil {
|
||||||
a.Missing = &missing
|
a.Missing = &missing
|
||||||
}
|
}
|
||||||
|
@ -70,6 +70,16 @@
|
|||||||
</label>
|
</label>
|
||||||
<input class="gf-form-input max-width-12" type="number" ng-model="agg.settings.trimEdges" ng-change="onChangeInternal()">
|
<input class="gf-form-input max-width-12" type="number" ng-model="agg.settings.trimEdges" ng-change="onChangeInternal()">
|
||||||
</div>
|
</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>
|
||||||
|
|
||||||
<div ng-if="agg.type === 'histogram'">
|
<div ng-if="agg.type === 'histogram'">
|
||||||
|
@ -72,6 +72,10 @@ export class ElasticQueryBuilder {
|
|||||||
esAgg.extended_bounds = { min: '$timeFrom', max: '$timeTo' };
|
esAgg.extended_bounds = { min: '$timeFrom', max: '$timeTo' };
|
||||||
esAgg.format = 'epoch_millis';
|
esAgg.format = 'epoch_millis';
|
||||||
|
|
||||||
|
if (settings.offset !== '') {
|
||||||
|
esAgg.offset = settings.offset;
|
||||||
|
}
|
||||||
|
|
||||||
if (esAgg.interval === 'auto') {
|
if (esAgg.interval === 'auto') {
|
||||||
esAgg.interval = '$__interval';
|
esAgg.interval = '$__interval';
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user