Commit f6fc7f7b by Mattia Rossi

Requested Backend changes, added details to popover description for the offset field

parent 98254841
...@@ -240,6 +240,7 @@ type DateHistogramAgg struct { ...@@ -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,9 @@ func addDateHistogramAgg(aggBuilder es.AggBuilder, bucketAgg *BucketAgg, timeFro ...@@ -134,6 +134,9 @@ func addDateHistogramAgg(aggBuilder es.AggBuilder, bucketAgg *BucketAgg, timeFro
a.Interval = "$__interval" a.Interval = "$__interval"
} }
if bucketAgg.Settings.Get("offset").MustString("") != "" {
a.Offset = bucketAgg.Settings.Get("offset").MustString("")
}
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
} }
......
...@@ -74,7 +74,8 @@ ...@@ -74,7 +74,8 @@
<label class="gf-form-label width-10"> <label class="gf-form-label width-10">
Offset Offset
<info-popover mode="right-normal"> <info-popover mode="right-normal">
Interval Offset 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,
see https://www.elastic.co/guide/en/elasticsearch/reference/current/common-options.html#time-units for further details
</info-popover> </info-popover>
</label> </label>
<input class="gf-form-input max-width-12" type="text" ng-model="agg.settings.offset" ng-change="onChangeInternal()"> <input class="gf-form-input max-width-12" type="text" ng-model="agg.settings.offset" ng-change="onChangeInternal()">
......
...@@ -71,7 +71,10 @@ export class ElasticQueryBuilder { ...@@ -71,7 +71,10 @@ export class ElasticQueryBuilder {
esAgg.min_doc_count = settings.min_doc_count || 0; esAgg.min_doc_count = settings.min_doc_count || 0;
esAgg.extended_bounds = { min: '$timeFrom', max: '$timeTo' }; esAgg.extended_bounds = { min: '$timeFrom', max: '$timeTo' };
esAgg.format = 'epoch_millis'; esAgg.format = 'epoch_millis';
esAgg.offset = settings.offset || '0';
if (settings.offset !== '') {
esAgg.offset = settings.offset;
}
if (esAgg.interval === 'auto') { if (esAgg.interval === 'auto') {
esAgg.interval = '$__interval'; 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