From e4c7353b43226e1ea312814ca58442eb8e852a60 Mon Sep 17 00:00:00 2001 From: Cristina Amico Date: Thu, 26 Jan 2023 13:31:54 +0100 Subject: [PATCH] [8.6] [Fleet] Add check for legacy managed_by field in datastream mappings (#149504) (#149583) # Backport This will backport the following commits from `main` to `8.6`: - [[Fleet] Add check for legacy managed_by field in datastream mappings (#149504)](https://github.com/elastic/kibana/pull/149504) ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) --- .../plugins/fleet/server/routes/data_streams/handlers.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/x-pack/plugins/fleet/server/routes/data_streams/handlers.ts b/x-pack/plugins/fleet/server/routes/data_streams/handlers.ts index 274ab22999ff8..27b29158bb28f 100644 --- a/x-pack/plugins/fleet/server/routes/data_streams/handlers.ts +++ b/x-pack/plugins/fleet/server/routes/data_streams/handlers.ts @@ -16,6 +16,8 @@ import { defaultFleetErrorHandler } from '../../errors'; import { getDataStreamsQueryMetadata } from './get_data_streams_query_metadata'; const DATA_STREAM_INDEX_PATTERN = 'logs-*-*,metrics-*-*,traces-*-*,synthetics-*-*'; +const MANAGED_BY = 'fleet'; +const LEGACY_MANAGED_BY = 'ingest-manager'; interface ESDataStreamInfo { name: string; @@ -59,8 +61,11 @@ export const getListHandler: RequestHandler = async (context, request, response) getPackageSavedObjects(savedObjects.client), ]); + // managed_by property 'ingest-manager' added to allow for legacy data streams to be displayed + // See https://github.com/elastic/elastic-agent/issues/654 + const filteredDataStreamsInfo = dataStreamsInfo.filter( - (ds) => ds?._meta?.managed_by === 'fleet' + (ds) => ds?._meta?.managed_by === MANAGED_BY || ds?._meta?.managed_by === LEGACY_MANAGED_BY ); const dataStreamsInfoByName = keyBy(filteredDataStreamsInfo, 'name'); @@ -121,6 +126,7 @@ export const getListHandler: RequestHandler = async (context, request, response) // Query additional information for each data stream const dataStreamPromises = dataStreamNames.map(async (dataStreamName) => { const dataStream = dataStreams[dataStreamName]; + const dataStreamResponse: DataStream = { index: dataStreamName, dataset: '',