Elasticsearch: Add support for Elasticsearch 8.0 (Beta) (#41729)
* use fixed_interval in date_histogram * Add 8.0 to available versions in datasource settings * Remove moving_avg from available metric aggregations * Add ES8 devenv * Update public/app/plugins/datasource/elasticsearch/components/QueryEditor/MetricAggregationsEditor/utils.ts Co-authored-by: Piotr Jamróz <pm.jamroz@gmail.com> * Add FE tests * Add BE test * fix FE test * fix BE test Co-authored-by: Piotr Jamróz <pm.jamroz@gmail.com>
This commit is contained in:
co-authored by
Piotr Jamróz
parent
ef1fb64bf5
commit
1b99d88337
@@ -239,6 +239,7 @@ type HistogramAgg struct {
|
||||
type DateHistogramAgg struct {
|
||||
Field string `json:"field"`
|
||||
Interval string `json:"interval,omitempty"`
|
||||
FixedInterval string `json:"fixed_interval,omitempty"`
|
||||
MinDocCount int `json:"min_doc_count"`
|
||||
Missing *string `json:"missing,omitempty"`
|
||||
ExtendedBounds *ExtendedBounds `json:"extended_bounds"`
|
||||
|
||||
@@ -342,6 +342,11 @@ func (b *aggBuilderImpl) DateHistogram(key, field string, fn func(a *DateHistogr
|
||||
fn(innerAgg, builder)
|
||||
}
|
||||
|
||||
if b.version.Major() >= 8 {
|
||||
innerAgg.FixedInterval = innerAgg.Interval
|
||||
innerAgg.Interval = ""
|
||||
}
|
||||
|
||||
b.aggDefs = append(b.aggDefs, aggDef)
|
||||
|
||||
return b
|
||||
|
||||
@@ -1049,6 +1049,62 @@ func TestSettingsCasting(t *testing.T) {
|
||||
|
||||
assert.Equal(t, 10, dateHistogramAgg.MinDocCount)
|
||||
})
|
||||
|
||||
t.Run("interval parameter", func(t *testing.T) {
|
||||
t.Run("Uses interval with ES < 8.0.0", func(t *testing.T) {
|
||||
c := newFakeClient("7.7.0")
|
||||
_, err := executeTsdbQuery(c, `{
|
||||
"timeField": "@timestamp",
|
||||
"bucketAggs": [
|
||||
{
|
||||
"type": "date_histogram",
|
||||
"field": "@timestamp",
|
||||
"id": "2",
|
||||
"settings": {
|
||||
"interval": "1d"
|
||||
}
|
||||
}
|
||||
],
|
||||
"metrics": [
|
||||
{ "id": "1", "type": "average", "field": "@value" }
|
||||
]
|
||||
}`, from, to, 15*time.Second)
|
||||
assert.Nil(t, err)
|
||||
sr := c.multisearchRequests[0].Requests[0]
|
||||
|
||||
dateHistogramAgg := sr.Aggs[0].Aggregation.Aggregation.(*es.DateHistogramAgg)
|
||||
|
||||
assert.Zero(t, dateHistogramAgg.FixedInterval)
|
||||
assert.NotZero(t, dateHistogramAgg.Interval)
|
||||
})
|
||||
|
||||
t.Run("Uses fixed_interval with ES >= 8.0.0", func(t *testing.T) {
|
||||
c := newFakeClient("8.0.0")
|
||||
_, err := executeTsdbQuery(c, `{
|
||||
"timeField": "@timestamp",
|
||||
"bucketAggs": [
|
||||
{
|
||||
"type": "date_histogram",
|
||||
"field": "@timestamp",
|
||||
"id": "2",
|
||||
"settings": {
|
||||
"interval": "1d"
|
||||
}
|
||||
}
|
||||
],
|
||||
"metrics": [
|
||||
{ "id": "1", "type": "average", "field": "@value" }
|
||||
]
|
||||
}`, from, to, 15*time.Second)
|
||||
assert.Nil(t, err)
|
||||
sr := c.multisearchRequests[0].Requests[0]
|
||||
|
||||
dateHistogramAgg := sr.Aggs[0].Aggregation.Aggregation.(*es.DateHistogramAgg)
|
||||
|
||||
assert.NotZero(t, dateHistogramAgg.FixedInterval)
|
||||
assert.Zero(t, dateHistogramAgg.Interval)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
t.Run("Inline Script", func(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user