From b43ffed76258b058a9d896fedf009e8c82ad94fa Mon Sep 17 00:00:00 2001 From: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Date: Fri, 18 Oct 2024 01:06:45 +1100 Subject: [PATCH] [8.x] [APM] Remove observability:searchExcludedDataTiers from serverless (#196380) (#196637) # Backport This will backport the following commits from `main` to `8.x`: - [[APM] Remove observability:searchExcludedDataTiers from serverless (#196380)](https://github.com/elastic/kibana/pull/196380) ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) Co-authored-by: Carlos Crespo Co-authored-by: Elastic Machine --- .../settings/observability_project/index.ts | 1 - .../create_es_client/create_apm_event_client/index.ts | 11 ++++++----- .../apm_data_access/server/lib/helpers/tier_filter.ts | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/serverless/settings/observability_project/index.ts b/packages/serverless/settings/observability_project/index.ts index f8bb8dbe12542..44f30e4320463 100644 --- a/packages/serverless/settings/observability_project/index.ts +++ b/packages/serverless/settings/observability_project/index.ts @@ -37,5 +37,4 @@ export const OBSERVABILITY_PROJECT_SETTINGS = [ settings.OBSERVABILITY_AI_ASSISTANT_SIMULATED_FUNCTION_CALLING, settings.OBSERVABILITY_AI_ASSISTANT_SEARCH_CONNECTOR_INDEX_PATTERN, settings.OBSERVABILITY_LOGS_DATA_ACCESS_LOG_SOURCES_ID, - settings.OBSERVABILITY_SEARCH_EXCLUDED_DATA_TIERS, ]; diff --git a/x-pack/plugins/observability_solution/apm_data_access/server/lib/helpers/create_es_client/create_apm_event_client/index.ts b/x-pack/plugins/observability_solution/apm_data_access/server/lib/helpers/create_es_client/create_apm_event_client/index.ts index c6c68830ae10c..cf376e7c78294 100644 --- a/x-pack/plugins/observability_solution/apm_data_access/server/lib/helpers/create_es_client/create_apm_event_client/index.ts +++ b/x-pack/plugins/observability_solution/apm_data_access/server/lib/helpers/create_es_client/create_apm_event_client/index.ts @@ -103,7 +103,7 @@ export class APMEventClient { /** @deprecated Use {@link excludedDataTiers} instead. * See https://www.elastic.co/guide/en/kibana/current/advanced-options.html **/ private readonly includeFrozen: boolean; - private readonly excludedDataTiers?: DataTier[]; + private readonly excludedDataTiers: DataTier[]; private readonly inspectableEsQueriesMap?: WeakMap; constructor(config: APMEventClientConfig) { @@ -112,7 +112,7 @@ export class APMEventClient { this.request = config.request; this.indices = config.indices; this.includeFrozen = config.options.includeFrozen; - this.excludedDataTiers = config.options.excludedDataTiers; + this.excludedDataTiers = config.options.excludedDataTiers ?? []; this.inspectableEsQueriesMap = config.options.inspectableEsQueriesMap; } @@ -167,7 +167,7 @@ export class APMEventClient { indices: this.indices, }); - if (this.excludedDataTiers) { + if (this.excludedDataTiers.length > 0) { filters.push(...excludeTiersQuery(this.excludedDataTiers)); } @@ -207,7 +207,8 @@ export class APMEventClient { // Reusing indices configured for errors since both events and errors are stored as logs. const index = processorEventsToIndex([ProcessorEvent.error], this.indices); - const filter = this.excludedDataTiers ? excludeTiersQuery(this.excludedDataTiers) : undefined; + const filter = + this.excludedDataTiers.length > 0 ? excludeTiersQuery(this.excludedDataTiers) : undefined; const searchParams = { ...omit(params, 'body'), @@ -249,7 +250,7 @@ export class APMEventClient { indices: this.indices, }); - if (this.excludedDataTiers) { + if (this.excludedDataTiers.length > 0) { filters.push(...excludeTiersQuery(this.excludedDataTiers)); } diff --git a/x-pack/plugins/observability_solution/apm_data_access/server/lib/helpers/tier_filter.ts b/x-pack/plugins/observability_solution/apm_data_access/server/lib/helpers/tier_filter.ts index ae29575c044c6..cad0b03579e3d 100644 --- a/x-pack/plugins/observability_solution/apm_data_access/server/lib/helpers/tier_filter.ts +++ b/x-pack/plugins/observability_solution/apm_data_access/server/lib/helpers/tier_filter.ts @@ -13,10 +13,10 @@ export function getDataTierFilterCombined({ excludedDataTiers, }: { filter?: QueryDslQueryContainer; - excludedDataTiers?: DataTier[]; + excludedDataTiers: DataTier[]; }): QueryDslQueryContainer | undefined { if (!filter) { - return excludedDataTiers ? excludeTiersQuery(excludedDataTiers)[0] : undefined; + return excludedDataTiers.length > 0 ? excludeTiersQuery(excludedDataTiers)[0] : undefined; } return !excludedDataTiers