From 77b1c97482886e71c76d405d64f1b6c7866c596c Mon Sep 17 00:00:00 2001 From: Ivana Huckova <30407135+ivanahuckova@users.noreply.github.com> Date: Wed, 20 Mar 2024 09:59:26 +0100 Subject: [PATCH] Elasticsearch: Remove xpack button and make includeFrozen not dependant on it (#84734) --- pkg/tsdb/elasticsearch/client/client.go | 3 +- pkg/tsdb/elasticsearch/client/client_test.go | 3 -- pkg/tsdb/elasticsearch/elasticsearch.go | 6 ---- pkg/tsdb/elasticsearch/querydata_test.go | 1 - .../configuration/ElasticDetails.tsx | 29 ++++++------------- .../elasticsearch/datasource.test.ts | 10 ++----- .../datasource/elasticsearch/datasource.ts | 4 +-- .../plugins/datasource/elasticsearch/types.ts | 1 - 8 files changed, 13 insertions(+), 44 deletions(-) diff --git a/pkg/tsdb/elasticsearch/client/client.go b/pkg/tsdb/elasticsearch/client/client.go index f35fba01946..b51b824e45b 100644 --- a/pkg/tsdb/elasticsearch/client/client.go +++ b/pkg/tsdb/elasticsearch/client/client.go @@ -38,7 +38,6 @@ type DatasourceInfo struct { Interval string MaxConcurrentShardRequests int64 IncludeFrozen bool - XPack bool } type ConfiguredFields struct { @@ -262,7 +261,7 @@ func (c *baseClientImpl) getMultiSearchQueryParameters() string { } qs = append(qs, fmt.Sprintf("max_concurrent_shard_requests=%d", maxConcurrentShardRequests)) - if c.ds.IncludeFrozen && c.ds.XPack { + if c.ds.IncludeFrozen { qs = append(qs, "ignore_throttled=false") } diff --git a/pkg/tsdb/elasticsearch/client/client_test.go b/pkg/tsdb/elasticsearch/client/client_test.go index 5f4483f2215..e857c385f5d 100644 --- a/pkg/tsdb/elasticsearch/client/client_test.go +++ b/pkg/tsdb/elasticsearch/client/client_test.go @@ -58,7 +58,6 @@ func TestClient_ExecuteMultisearch(t *testing.T) { Interval: "Daily", MaxConcurrentShardRequests: 6, IncludeFrozen: true, - XPack: true, } from := time.Date(2018, 5, 15, 17, 50, 0, 0, time.UTC) @@ -148,7 +147,6 @@ func TestClient_ExecuteMultisearch(t *testing.T) { Interval: "Daily", MaxConcurrentShardRequests: 6, IncludeFrozen: true, - XPack: true, } from := time.Date(2018, 5, 15, 17, 50, 0, 0, time.UTC) @@ -253,7 +251,6 @@ func TestClient_Index(t *testing.T) { Interval: test.patternInDatasource, MaxConcurrentShardRequests: 6, IncludeFrozen: true, - XPack: true, } from := time.Date(2018, 5, 10, 17, 50, 0, 0, time.UTC) diff --git a/pkg/tsdb/elasticsearch/elasticsearch.go b/pkg/tsdb/elasticsearch/elasticsearch.go index a79a76df918..28fe2bb824e 100644 --- a/pkg/tsdb/elasticsearch/elasticsearch.go +++ b/pkg/tsdb/elasticsearch/elasticsearch.go @@ -157,11 +157,6 @@ func newInstanceSettings(httpClientProvider httpclient.Provider) datasource.Inst includeFrozen = false } - xpack, ok := jsonData["xpack"].(bool) - if !ok { - xpack = false - } - configuredFields := es.ConfiguredFields{ TimeField: timeField, LogLevelField: logLevelField, @@ -177,7 +172,6 @@ func newInstanceSettings(httpClientProvider httpclient.Provider) datasource.Inst ConfiguredFields: configuredFields, Interval: interval, IncludeFrozen: includeFrozen, - XPack: xpack, } return model, nil } diff --git a/pkg/tsdb/elasticsearch/querydata_test.go b/pkg/tsdb/elasticsearch/querydata_test.go index d3e7d1f2af4..eeb3be175d7 100644 --- a/pkg/tsdb/elasticsearch/querydata_test.go +++ b/pkg/tsdb/elasticsearch/querydata_test.go @@ -57,7 +57,6 @@ func newFlowTestDsInfo(body []byte, statusCode int, requestCallback func(req *ht HTTPClient: &client, MaxConcurrentShardRequests: 42, IncludeFrozen: false, - XPack: true, } } diff --git a/public/app/plugins/datasource/elasticsearch/configuration/ElasticDetails.tsx b/public/app/plugins/datasource/elasticsearch/configuration/ElasticDetails.tsx index cafaacf2283..4b8707e465e 100644 --- a/public/app/plugins/datasource/elasticsearch/configuration/ElasticDetails.tsx +++ b/public/app/plugins/datasource/elasticsearch/configuration/ElasticDetails.tsx @@ -115,29 +115,18 @@ export const ElasticDetails = ({ value, onChange }: Props) => { placeholder="10s" /> - - + - - {value.jsonData.xpack && ( - - - - )} ); }; diff --git a/public/app/plugins/datasource/elasticsearch/datasource.test.ts b/public/app/plugins/datasource/elasticsearch/datasource.test.ts index 7fd3446dcfb..b0ed2a0de6b 100644 --- a/public/app/plugins/datasource/elasticsearch/datasource.test.ts +++ b/public/app/plugins/datasource/elasticsearch/datasource.test.ts @@ -1056,19 +1056,13 @@ describe('ElasticDatasource', () => { describe('getMultiSearchUrl', () => { it('Should add correct params to URL if "includeFrozen" is enabled', () => { - const { ds } = getTestContext({ jsonData: { includeFrozen: true, xpack: true } }); + const { ds } = getTestContext({ jsonData: { includeFrozen: true } }); expect(ds.getMultiSearchUrl()).toMatch(/ignore_throttled=false/); }); it('Should NOT add ignore_throttled if "includeFrozen" is disabled', () => { - const { ds } = getTestContext({ jsonData: { includeFrozen: false, xpack: true } }); - - expect(ds.getMultiSearchUrl()).not.toMatch(/ignore_throttled=false/); - }); - - it('Should NOT add ignore_throttled if "xpack" is disabled', () => { - const { ds } = getTestContext({ jsonData: { includeFrozen: true, xpack: false } }); + const { ds } = getTestContext({ jsonData: { includeFrozen: false } }); expect(ds.getMultiSearchUrl()).not.toMatch(/ignore_throttled=false/); }); diff --git a/public/app/plugins/datasource/elasticsearch/datasource.ts b/public/app/plugins/datasource/elasticsearch/datasource.ts index 7fab51613c9..5547eadcf40 100644 --- a/public/app/plugins/datasource/elasticsearch/datasource.ts +++ b/public/app/plugins/datasource/elasticsearch/datasource.ts @@ -115,7 +115,6 @@ export class ElasticDatasource name: string; index: string; timeField: string; - xpack: boolean; interval: string; maxConcurrentShardRequests?: number; queryBuilder: ElasticQueryBuilder; @@ -144,7 +143,6 @@ export class ElasticDatasource this.index = settingsData.index ?? instanceSettings.database ?? ''; this.timeField = settingsData.timeField; - this.xpack = Boolean(settingsData.xpack); this.indexPattern = new IndexPattern(this.index, settingsData.interval); this.intervalPattern = settingsData.interval; this.interval = settingsData.timeInterval; @@ -827,7 +825,7 @@ export class ElasticDatasource searchParams.append('max_concurrent_shard_requests', `${this.maxConcurrentShardRequests}`); } - if (this.xpack && this.includeFrozen) { + if (this.includeFrozen) { searchParams.append('ignore_throttled', 'false'); } diff --git a/public/app/plugins/datasource/elasticsearch/types.ts b/public/app/plugins/datasource/elasticsearch/types.ts index 9e3a610b895..9e88e4d3b3a 100644 --- a/public/app/plugins/datasource/elasticsearch/types.ts +++ b/public/app/plugins/datasource/elasticsearch/types.ts @@ -56,7 +56,6 @@ export interface ElasticsearchOptions extends DataSourceJsonData { timeField: string; // we used to have a field named `esVersion` in the past, // please do not use that name in the future. - xpack?: boolean; interval?: Interval; timeInterval: string; maxConcurrentShardRequests?: number;