From f6fc7f7b64f7f51e519c722459f849765f6d55fb Mon Sep 17 00:00:00 2001 From: Mattia Rossi Date: Mon, 26 Nov 2018 08:58:25 -0500 Subject: [PATCH] Requested Backend changes, added details to popover description for the offset field --- pkg/tsdb/elasticsearch/client/models.go | 1 + pkg/tsdb/elasticsearch/time_series_query.go | 3 +++ .../datasource/elasticsearch/partials/bucket_agg.html | 3 ++- public/app/plugins/datasource/elasticsearch/query_builder.ts | 5 ++++- 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/pkg/tsdb/elasticsearch/client/models.go b/pkg/tsdb/elasticsearch/client/models.go index a0d257d01a6..5307dc34b27 100644 --- a/pkg/tsdb/elasticsearch/client/models.go +++ b/pkg/tsdb/elasticsearch/client/models.go @@ -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 diff --git a/pkg/tsdb/elasticsearch/time_series_query.go b/pkg/tsdb/elasticsearch/time_series_query.go index 869e23e21ce..3e43a26089a 100644 --- a/pkg/tsdb/elasticsearch/time_series_query.go +++ b/pkg/tsdb/elasticsearch/time_series_query.go @@ -134,6 +134,9 @@ func addDateHistogramAgg(aggBuilder es.AggBuilder, bucketAgg *BucketAgg, timeFro 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 { a.Missing = &missing } diff --git a/public/app/plugins/datasource/elasticsearch/partials/bucket_agg.html b/public/app/plugins/datasource/elasticsearch/partials/bucket_agg.html index a6f68685681..9d6b8196e8e 100644 --- a/public/app/plugins/datasource/elasticsearch/partials/bucket_agg.html +++ b/public/app/plugins/datasource/elasticsearch/partials/bucket_agg.html @@ -74,7 +74,8 @@ diff --git a/public/app/plugins/datasource/elasticsearch/query_builder.ts b/public/app/plugins/datasource/elasticsearch/query_builder.ts index 7d9490521e3..c505d402874 100644 --- a/public/app/plugins/datasource/elasticsearch/query_builder.ts +++ b/public/app/plugins/datasource/elasticsearch/query_builder.ts @@ -71,7 +71,10 @@ export class ElasticQueryBuilder { esAgg.min_doc_count = settings.min_doc_count || 0; esAgg.extended_bounds = { min: '$timeFrom', max: '$timeTo' }; esAgg.format = 'epoch_millis'; - esAgg.offset = settings.offset || '0'; + + if (settings.offset !== '') { + esAgg.offset = settings.offset; + } if (esAgg.interval === 'auto') { esAgg.interval = '$__interval';