From f1918769b4717e9a5a40ceb421f09af0f03b72d8 Mon Sep 17 00:00:00 2001 From: Carlos Crespo Date: Mon, 9 Sep 2024 15:39:43 +0200 Subject: [PATCH] Use excluded_data_tiers setting in APM query clients Update config key --- .../apm/common/storage_explorer_types.ts | 20 +++------ .../lib/helpers/get_apm_event_client.ts | 20 ++++++--- .../routes/alerts/alerting_es_client.ts | 22 ++++++++++ .../get_service_group_fields_for_anomaly.ts | 9 +++- .../anomaly/register_anomaly_rule_type.ts | 3 +- .../register_error_count_rule_type.ts | 3 +- ...register_transaction_duration_rule_type.ts | 3 +- ...gister_transaction_error_rate_rule_type.ts | 3 +- .../has_historical_agent_data.ts | 7 ++- .../create_apm_event_client/index.ts | 32 +++++++++++++- .../server/lib/helpers/index.ts | 2 + .../server/lib/helpers/tier_filter.ts | 44 +++++++++++++++++++ .../apm_data_access/server/utils.ts | 1 + .../observability_shared/common/ilm_types.ts | 24 ++++++++++ .../observability_shared/common/index.ts | 5 +++ .../profiling/common/storage_explorer.ts | 20 +++------ 16 files changed, 174 insertions(+), 44 deletions(-) create mode 100644 x-pack/plugins/observability_solution/apm_data_access/server/lib/helpers/tier_filter.ts create mode 100644 x-pack/plugins/observability_solution/observability_shared/common/ilm_types.ts diff --git a/x-pack/plugins/observability_solution/apm/common/storage_explorer_types.ts b/x-pack/plugins/observability_solution/apm/common/storage_explorer_types.ts index 579417a0f8e03..b6db4dd7405b9 100644 --- a/x-pack/plugins/observability_solution/apm/common/storage_explorer_types.ts +++ b/x-pack/plugins/observability_solution/apm/common/storage_explorer_types.ts @@ -5,23 +5,13 @@ * 2.0. */ +import { + IndexLifecyclePhaseSelectOption, + indexLifeCyclePhaseToDataTier, +} from '@kbn/observability-shared-plugin/common'; import * as t from 'io-ts'; -export enum IndexLifecyclePhaseSelectOption { - All = 'all', - Hot = 'hot', - Warm = 'warm', - Cold = 'cold', - Frozen = 'frozen', -} - -export const indexLifeCyclePhaseToDataTier = { - [IndexLifecyclePhaseSelectOption.Hot]: 'data_hot', - [IndexLifecyclePhaseSelectOption.Warm]: 'data_warm', - [IndexLifecyclePhaseSelectOption.Cold]: 'data_cold', - [IndexLifecyclePhaseSelectOption.Frozen]: 'data_frozen', -}; - +export { IndexLifecyclePhaseSelectOption, indexLifeCyclePhaseToDataTier }; export const indexLifecyclePhaseRt = t.type({ indexLifecyclePhase: t.union([ t.literal(IndexLifecyclePhaseSelectOption.All), diff --git a/x-pack/plugins/observability_solution/apm/server/lib/helpers/get_apm_event_client.ts b/x-pack/plugins/observability_solution/apm/server/lib/helpers/get_apm_event_client.ts index 8f21bf8f1c691..ab48d13cce237 100644 --- a/x-pack/plugins/observability_solution/apm/server/lib/helpers/get_apm_event_client.ts +++ b/x-pack/plugins/observability_solution/apm/server/lib/helpers/get_apm_event_client.ts @@ -6,6 +6,8 @@ */ import { UI_SETTINGS } from '@kbn/data-plugin/common'; +import { IndexLifeCycleDataTier } from '@kbn/observability-shared-plugin/common'; +import { searchExcludedDataTiers } from '@kbn/observability-plugin/common/ui_settings_keys'; import { APMEventClient } from './create_es_client/create_apm_event_client'; import { withApmSpan } from '../../utils/with_apm_span'; import { MinimalAPMRouteHandlerResources } from '../../routes/apm_routes/register_apm_server_routes'; @@ -22,11 +24,18 @@ export async function getApmEventClient({ >): Promise { return withApmSpan('get_apm_event_client', async () => { const coreContext = await context.core; - const [indices, includeFrozen] = await Promise.all([ + const [indices, uiSettings] = await Promise.all([ getApmIndices(), - withApmSpan('get_ui_settings', () => - coreContext.uiSettings.client.get(UI_SETTINGS.SEARCH_INCLUDE_FROZEN) - ), + withApmSpan('get_ui_settings', async () => { + const includeFrozen = await coreContext.uiSettings.client.get( + UI_SETTINGS.SEARCH_INCLUDE_FROZEN + ); + const excludedDataTiers = await coreContext.uiSettings.client.get( + searchExcludedDataTiers + ); + + return { includeFrozen, excludedDataTiers }; + }), ]); return new APMEventClient({ @@ -35,7 +44,8 @@ export async function getApmEventClient({ request, indices, options: { - includeFrozen, + includeFrozen: uiSettings.includeFrozen, + excludedDataTiers: uiSettings.excludedDataTiers, inspectableEsQueriesMap, }, }); diff --git a/x-pack/plugins/observability_solution/apm/server/routes/alerts/alerting_es_client.ts b/x-pack/plugins/observability_solution/apm/server/routes/alerts/alerting_es_client.ts index 1a9daf6ad41a6..34e517354989a 100644 --- a/x-pack/plugins/observability_solution/apm/server/routes/alerts/alerting_es_client.ts +++ b/x-pack/plugins/observability_solution/apm/server/routes/alerts/alerting_es_client.ts @@ -7,6 +7,11 @@ import type { ESSearchRequest, ESSearchResponse } from '@kbn/es-types'; import { RuleExecutorServices } from '@kbn/alerting-plugin/server'; +import { IUiSettingsClient } from '@kbn/core/server'; +import { IndexLifeCycleDataTier } from '@kbn/observability-shared-plugin/common'; +import { getExcludedDataTiersFilter } from '@kbn/apm-data-access-plugin/server/utils'; +import { compact } from 'lodash'; +import { searchExcludedDataTiers } from '@kbn/observability-plugin/common/ui_settings_keys'; export type APMEventESSearchRequestParams = ESSearchRequest & { body: { size: number; track_total_hits: boolean | number }; @@ -14,13 +19,30 @@ export type APMEventESSearchRequestParams = ESSearchRequest & { export async function alertingEsClient({ scopedClusterClient, + uiSettingsClient, params, }: { scopedClusterClient: RuleExecutorServices['scopedClusterClient']; + uiSettingsClient: IUiSettingsClient; params: TParams; }): Promise> { + const excludedDataTiers = await uiSettingsClient.get( + searchExcludedDataTiers + ); + + const filter = excludedDataTiers ? getExcludedDataTiersFilter(excludedDataTiers) : undefined; + const response = await scopedClusterClient.asCurrentUser.search({ ...params, + body: { + ...params.body, + query: { + bool: { + filter, + must: compact([params.body.query]), + }, + }, + }, ignore_unavailable: true, }); diff --git a/x-pack/plugins/observability_solution/apm/server/routes/alerts/rule_types/anomaly/get_service_group_fields_for_anomaly.ts b/x-pack/plugins/observability_solution/apm/server/routes/alerts/rule_types/anomaly/get_service_group_fields_for_anomaly.ts index ce8783ad517f9..39de017668454 100644 --- a/x-pack/plugins/observability_solution/apm/server/routes/alerts/rule_types/anomaly/get_service_group_fields_for_anomaly.ts +++ b/x-pack/plugins/observability_solution/apm/server/routes/alerts/rule_types/anomaly/get_service_group_fields_for_anomaly.ts @@ -5,7 +5,11 @@ * 2.0. */ -import { IScopedClusterClient, SavedObjectsClientContract } from '@kbn/core/server'; +import { + IScopedClusterClient, + IUiSettingsClient, + SavedObjectsClientContract, +} from '@kbn/core/server'; import type { APMIndices } from '@kbn/apm-data-access-plugin/server'; import { SERVICE_ENVIRONMENT, @@ -23,6 +27,7 @@ export async function getServiceGroupFieldsForAnomaly({ apmIndices, scopedClusterClient, serviceName, + uiSettingsClient, environment, transactionType, timestamp, @@ -31,6 +36,7 @@ export async function getServiceGroupFieldsForAnomaly({ apmIndices: APMIndices; scopedClusterClient: IScopedClusterClient; savedObjectsClient: SavedObjectsClientContract; + uiSettingsClient: IUiSettingsClient; serviceName: string; environment: string; transactionType: string; @@ -70,6 +76,7 @@ export async function getServiceGroupFieldsForAnomaly({ const response = await alertingEsClient({ scopedClusterClient, + uiSettingsClient, params, }); diff --git a/x-pack/plugins/observability_solution/apm/server/routes/alerts/rule_types/anomaly/register_anomaly_rule_type.ts b/x-pack/plugins/observability_solution/apm/server/routes/alerts/rule_types/anomaly/register_anomaly_rule_type.ts index 4678622a7d122..d9a58d23a5888 100644 --- a/x-pack/plugins/observability_solution/apm/server/routes/alerts/rule_types/anomaly/register_anomaly_rule_type.ts +++ b/x-pack/plugins/observability_solution/apm/server/routes/alerts/rule_types/anomaly/register_anomaly_rule_type.ts @@ -129,7 +129,7 @@ export function registerAnomalyRuleType({ } const { params, services, spaceId, startedAt, getTimeRange } = options; - const { alertsClient, savedObjectsClient, scopedClusterClient } = services; + const { alertsClient, savedObjectsClient, scopedClusterClient, uiSettingsClient } = services; if (!alertsClient) { throw new AlertsClientError(); } @@ -283,6 +283,7 @@ export function registerAnomalyRuleType({ apmIndices, scopedClusterClient, savedObjectsClient, + uiSettingsClient, serviceName, environment, transactionType, diff --git a/x-pack/plugins/observability_solution/apm/server/routes/alerts/rule_types/error_count/register_error_count_rule_type.ts b/x-pack/plugins/observability_solution/apm/server/routes/alerts/rule_types/error_count/register_error_count_rule_type.ts index d90aa0e143a14..2539a63ea8575 100644 --- a/x-pack/plugins/observability_solution/apm/server/routes/alerts/rule_types/error_count/register_error_count_rule_type.ts +++ b/x-pack/plugins/observability_solution/apm/server/routes/alerts/rule_types/error_count/register_error_count_rule_type.ts @@ -128,7 +128,7 @@ export function registerErrorCountRuleType({ > ) => { const { params: ruleParams, services, spaceId, startedAt, getTimeRange } = options; - const { alertsClient, savedObjectsClient, scopedClusterClient } = services; + const { alertsClient, savedObjectsClient, scopedClusterClient, uiSettingsClient } = services; if (!alertsClient) { throw new AlertsClientError(); } @@ -187,6 +187,7 @@ export function registerErrorCountRuleType({ const response = await alertingEsClient({ scopedClusterClient, + uiSettingsClient, params: searchParams, }); diff --git a/x-pack/plugins/observability_solution/apm/server/routes/alerts/rule_types/transaction_duration/register_transaction_duration_rule_type.ts b/x-pack/plugins/observability_solution/apm/server/routes/alerts/rule_types/transaction_duration/register_transaction_duration_rule_type.ts index 299615e7663ef..96ddbe15c4287 100644 --- a/x-pack/plugins/observability_solution/apm/server/routes/alerts/rule_types/transaction_duration/register_transaction_duration_rule_type.ts +++ b/x-pack/plugins/observability_solution/apm/server/routes/alerts/rule_types/transaction_duration/register_transaction_duration_rule_type.ts @@ -140,7 +140,7 @@ export function registerTransactionDurationRuleType({ > ) => { const { params: ruleParams, services, spaceId, getTimeRange } = options; - const { alertsClient, savedObjectsClient, scopedClusterClient } = services; + const { alertsClient, savedObjectsClient, scopedClusterClient, uiSettingsClient } = services; if (!alertsClient) { throw new AlertsClientError(); } @@ -221,6 +221,7 @@ export function registerTransactionDurationRuleType({ const response = await alertingEsClient({ scopedClusterClient, + uiSettingsClient, params: searchParams, }); diff --git a/x-pack/plugins/observability_solution/apm/server/routes/alerts/rule_types/transaction_error_rate/register_transaction_error_rate_rule_type.ts b/x-pack/plugins/observability_solution/apm/server/routes/alerts/rule_types/transaction_error_rate/register_transaction_error_rate_rule_type.ts index 81b4612244b1b..cff5a481f9200 100644 --- a/x-pack/plugins/observability_solution/apm/server/routes/alerts/rule_types/transaction_error_rate/register_transaction_error_rate_rule_type.ts +++ b/x-pack/plugins/observability_solution/apm/server/routes/alerts/rule_types/transaction_error_rate/register_transaction_error_rate_rule_type.ts @@ -138,7 +138,7 @@ export function registerTransactionErrorRateRuleType({ > ) => { const { services, spaceId, params: ruleParams, startedAt, getTimeRange } = options; - const { alertsClient, savedObjectsClient, scopedClusterClient } = services; + const { alertsClient, savedObjectsClient, scopedClusterClient, uiSettingsClient } = services; if (!alertsClient) { throw new AlertsClientError(); } @@ -223,6 +223,7 @@ export function registerTransactionErrorRateRuleType({ const response = await alertingEsClient({ scopedClusterClient, + uiSettingsClient, params: searchParams, }); diff --git a/x-pack/plugins/observability_solution/apm/server/routes/historical_data/has_historical_agent_data.ts b/x-pack/plugins/observability_solution/apm/server/routes/historical_data/has_historical_agent_data.ts index 1b34aa001dd93..fbb682ce3e05f 100644 --- a/x-pack/plugins/observability_solution/apm/server/routes/historical_data/has_historical_agent_data.ts +++ b/x-pack/plugins/observability_solution/apm/server/routes/historical_data/has_historical_agent_data.ts @@ -6,6 +6,7 @@ */ import { ProcessorEvent } from '@kbn/observability-plugin/common'; +import type { IndexLifeCycleDataTier } from '@kbn/observability-shared-plugin/common'; import { APMEventClient } from '../../lib/helpers/create_es_client/create_apm_event_client'; export async function hasHistoricalAgentData(apmEventClient: APMEventClient) { @@ -23,8 +24,10 @@ export async function hasHistoricalAgentData(apmEventClient: APMEventClient) { return hasDataUnbounded; } -type DataTier = 'data_hot' | 'data_warm' | 'data_cold' | 'data_frozen'; -async function hasDataRequest(apmEventClient: APMEventClient, dataTiers?: DataTier[]) { +async function hasDataRequest( + apmEventClient: APMEventClient, + dataTiers?: IndexLifeCycleDataTier[] +) { const query = dataTiers ? { terms: { _tier: dataTiers } } : undefined; const params = { 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 3c195b752c854..d1066207696ef 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 @@ -22,6 +22,7 @@ import { compact, omit } from 'lodash'; import { ValuesType } from 'utility-types'; import type { APMError, Metric, Span, Transaction, Event } from '@kbn/apm-types/es_schemas_ui'; import type { InspectResponse } from '@kbn/observability-plugin/typings/common'; +import type { IndexLifeCycleDataTier } from '@kbn/observability-shared-plugin/common'; import { withApmSpan } from '../../../../utils'; import type { ApmDataSource } from '../../../../../common/data_source'; import { cancelEsRequestOnAbort } from '../cancel_es_request_on_abort'; @@ -29,6 +30,7 @@ import { callAsyncWithDebug, getDebugBody, getDebugTitle } from '../call_async_w import type { ProcessorEventOfDocumentType } from '../document_type'; import type { APMIndices } from '../../../..'; import { getRequestBase, processorEventsToIndex } from './get_request_base'; +import { getExcludedDataTiersFilter, getIndexFilter } from '../../tier_filter'; export type APMEventESSearchRequest = Omit & { apm: { @@ -88,6 +90,7 @@ export interface APMEventClientConfig { options: { includeFrozen: boolean; inspectableEsQueriesMap?: WeakMap; + excludedDataTiers?: IndexLifeCycleDataTier; }; } @@ -96,7 +99,10 @@ export class APMEventClient { private readonly debug: boolean; private readonly request: KibanaRequest; public readonly indices: APMIndices; + /** @deprecated Use {@link excludedDataTiers} instead. + * See https://www.elastic.co/guide/en/kibana/current/advanced-options.html **/ private readonly includeFrozen: boolean; + private readonly excludedDataTiers?: IndexLifeCycleDataTier; private readonly inspectableEsQueriesMap?: WeakMap; constructor(config: APMEventClientConfig) { @@ -105,6 +111,7 @@ export class APMEventClient { this.request = config.request; this.indices = config.indices; this.includeFrozen = config.options.includeFrozen; + this.excludedDataTiers = config.options.excludedDataTiers; this.inspectableEsQueriesMap = config.options.inspectableEsQueriesMap; } @@ -159,6 +166,10 @@ export class APMEventClient { indices: this.indices, }); + if (this.excludedDataTiers) { + filters.push(getExcludedDataTiersFilter(this.excludedDataTiers)); + } + const searchParams = { ...omit(params, 'apm', 'body'), index, @@ -195,6 +206,10 @@ 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 + ? getExcludedDataTiersFilter(this.excludedDataTiers) + : undefined; + const searchParams = { ...omit(params, 'body'), index, @@ -202,6 +217,7 @@ export class APMEventClient { ...params.body, query: { bool: { + filter, must: compact([params.body.query]), }, }, @@ -234,6 +250,10 @@ export class APMEventClient { indices: this.indices, }); + if (this.excludedDataTiers) { + filters.push(getExcludedDataTiersFilter(this.excludedDataTiers)); + } + const searchParams: [MsearchMultisearchHeader, MsearchMultisearchBody] = [ { index, @@ -295,9 +315,13 @@ export class APMEventClient { ): Promise { const index = processorEventsToIndex(params.apm.events, this.indices); - const requestParams = { + const requestParams: Omit & { index: string[] } = { ...omit(params, 'apm'), index, + index_filter: getIndexFilter({ + indexFilter: params.index_filter, + excludedDataTiers: this.excludedDataTiers, + }), }; return this.callAsyncWithDebug({ @@ -314,9 +338,13 @@ export class APMEventClient { ): Promise { const index = processorEventsToIndex(params.apm.events, this.indices); - const requestParams = { + const requestParams: Omit & { index: string } = { ...omit(params, 'apm'), index: index.join(','), + index_filter: getIndexFilter({ + indexFilter: params.index_filter, + excludedDataTiers: this.excludedDataTiers, + }), }; return this.callAsyncWithDebug({ diff --git a/x-pack/plugins/observability_solution/apm_data_access/server/lib/helpers/index.ts b/x-pack/plugins/observability_solution/apm_data_access/server/lib/helpers/index.ts index 30a2ff30d98ee..4cfbbb4d1ae01 100644 --- a/x-pack/plugins/observability_solution/apm_data_access/server/lib/helpers/index.ts +++ b/x-pack/plugins/observability_solution/apm_data_access/server/lib/helpers/index.ts @@ -21,3 +21,5 @@ export { } from './create_es_client/call_async_with_debug'; export { cancelEsRequestOnAbort } from './create_es_client/cancel_es_request_on_abort'; + +export { getExcludedDataTiersFilter } from './tier_filter'; 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 new file mode 100644 index 0000000000000..e4f4e881d3465 --- /dev/null +++ b/x-pack/plugins/observability_solution/apm_data_access/server/lib/helpers/tier_filter.ts @@ -0,0 +1,44 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ +import type { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; +import type { IndexLifeCycleDataTier } from '@kbn/observability-shared-plugin/common'; + +export function getExcludedDataTiersFilter( + excludedDataTiers: IndexLifeCycleDataTier +): QueryDslQueryContainer { + return { + bool: { + must_not: [ + { + terms: { + _tier: excludedDataTiers, + }, + }, + ], + }, + }; +} + +export function getIndexFilter({ + indexFilter, + excludedDataTiers, +}: { + indexFilter?: QueryDslQueryContainer; + excludedDataTiers?: IndexLifeCycleDataTier; +}): QueryDslQueryContainer | undefined { + if (!indexFilter) { + return excludedDataTiers ? getExcludedDataTiersFilter(excludedDataTiers) : undefined; + } + + return !excludedDataTiers + ? indexFilter + : { + bool: { + must: [indexFilter, getExcludedDataTiersFilter(excludedDataTiers)], + }, + }; +} diff --git a/x-pack/plugins/observability_solution/apm_data_access/server/utils.ts b/x-pack/plugins/observability_solution/apm_data_access/server/utils.ts index b1e768edf3733..e7fc88a47eb03 100644 --- a/x-pack/plugins/observability_solution/apm_data_access/server/utils.ts +++ b/x-pack/plugins/observability_solution/apm_data_access/server/utils.ts @@ -11,6 +11,7 @@ export { cancelEsRequestOnAbort, getDebugBody, getDebugTitle, + getExcludedDataTiersFilter, } from './lib/helpers'; export { withApmSpan } from './utils/with_apm_span'; diff --git a/x-pack/plugins/observability_solution/observability_shared/common/ilm_types.ts b/x-pack/plugins/observability_solution/observability_shared/common/ilm_types.ts new file mode 100644 index 0000000000000..eec1b17ebb424 --- /dev/null +++ b/x-pack/plugins/observability_solution/observability_shared/common/ilm_types.ts @@ -0,0 +1,24 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +export enum IndexLifecyclePhaseSelectOption { + All = 'all', + Hot = 'hot', + Warm = 'warm', + Cold = 'cold', + Frozen = 'frozen', +} + +export const indexLifeCyclePhaseToDataTier = { + [IndexLifecyclePhaseSelectOption.Hot]: 'data_hot', + [IndexLifecyclePhaseSelectOption.Warm]: 'data_warm', + [IndexLifecyclePhaseSelectOption.Cold]: 'data_cold', + [IndexLifecyclePhaseSelectOption.Frozen]: 'data_frozen', +} as const; + +export type IndexLifeCycleDataTier = + (typeof indexLifeCyclePhaseToDataTier)[keyof typeof indexLifeCyclePhaseToDataTier]; diff --git a/x-pack/plugins/observability_solution/observability_shared/common/index.ts b/x-pack/plugins/observability_solution/observability_shared/common/index.ts index ab49080f313ba..7e62b01ff6b06 100644 --- a/x-pack/plugins/observability_solution/observability_shared/common/index.ts +++ b/x-pack/plugins/observability_solution/observability_shared/common/index.ts @@ -144,6 +144,11 @@ export { export { type Color, colorTransformer } from './color_palette'; export { ObservabilityTriggerId } from './trigger_ids'; export { getInspectResponse } from './utils/get_inspect_response'; +export { + type IndexLifeCycleDataTier, + indexLifeCyclePhaseToDataTier, + IndexLifecyclePhaseSelectOption, +} from './ilm_types'; export const LOGS_ONBOARDING_FEEDBACK_LINK = 'https://ela.st/logs-onboarding-feedback'; export const LOGS_EXPLORER_FEEDBACK_LINK = 'https://ela.st/explorer-feedback'; diff --git a/x-pack/plugins/observability_solution/profiling/common/storage_explorer.ts b/x-pack/plugins/observability_solution/profiling/common/storage_explorer.ts index 984619af5ea98..f55f2da1b37a0 100644 --- a/x-pack/plugins/observability_solution/profiling/common/storage_explorer.ts +++ b/x-pack/plugins/observability_solution/profiling/common/storage_explorer.ts @@ -4,16 +4,13 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ +import { + IndexLifecyclePhaseSelectOption, + indexLifeCyclePhaseToDataTier, +} from '@kbn/observability-shared-plugin/common'; import * as t from 'io-ts'; -export enum IndexLifecyclePhaseSelectOption { - All = 'all', - Hot = 'hot', - Warm = 'warm', - Cold = 'cold', - Frozen = 'frozen', -} - +export { IndexLifecyclePhaseSelectOption, type indexLifeCyclePhaseToDataTier }; export const indexLifecyclePhaseRt = t.type({ indexLifecyclePhase: t.union([ t.literal(IndexLifecyclePhaseSelectOption.All), @@ -24,13 +21,6 @@ export const indexLifecyclePhaseRt = t.type({ ]), }); -export const indexLifeCyclePhaseToDataTier = { - [IndexLifecyclePhaseSelectOption.Hot]: 'data_hot', - [IndexLifecyclePhaseSelectOption.Warm]: 'data_warm', - [IndexLifecyclePhaseSelectOption.Cold]: 'data_cold', - [IndexLifecyclePhaseSelectOption.Frozen]: 'data_frozen', -}; - export interface StorageExplorerSummaryAPIResponse { totalProfilingSizeBytes: number; totalSymbolsSizeBytes: number;