From a176c0fdd7815e5841ed78f5213f1296226b276e Mon Sep 17 00:00:00 2001 From: Marco Antonio Ghiani Date: Wed, 11 Dec 2024 11:41:28 +0100 Subject: [PATCH] [Logs] Deprecate HTTP APIs used in LogStream app (#201974) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 📓 Summary Closes #200968 These changes deprecate internal APIs used by the LogStream app, which is also deprecated. With v9, any internal API will become unreachable from external origins. In case we get an external request to these APIs (although it should be less likely to happen), the deprecation will be surfaced on the Upgrade Assistant UI as a warning. Screenshot 2024-11-27 at 13 16 39 Screenshot 2024-11-27 at 13 16 25 Co-authored-by: Marco Antonio Ghiani --- .../server/routes/log_entries/highlights.ts | 15 +++++++++++++++ .../server/routes/log_entries/summary.ts | 15 +++++++++++++++ .../routes/log_entries/summary_highlights.ts | 15 +++++++++++++++ .../server/routes/log_views/get_log_view.ts | 12 ++++++++++++ .../server/routes/log_views/put_log_view.ts | 12 ++++++++++++ .../services/log_entries/log_entries_service.ts | 10 ++++++++++ 6 files changed, 79 insertions(+) diff --git a/x-pack/plugins/observability_solution/logs_shared/server/routes/log_entries/highlights.ts b/x-pack/plugins/observability_solution/logs_shared/server/routes/log_entries/highlights.ts index e8019c58d6000..dedf3ced27f28 100644 --- a/x-pack/plugins/observability_solution/logs_shared/server/routes/log_entries/highlights.ts +++ b/x-pack/plugins/observability_solution/logs_shared/server/routes/log_entries/highlights.ts @@ -12,6 +12,7 @@ import { fold } from 'fp-ts/lib/Either'; import { identity } from 'fp-ts/lib/function'; import { schema } from '@kbn/config-schema'; +import { i18n } from '@kbn/i18n'; import { logEntriesV1 } from '../../../common/http_api'; import { throwErrors } from '../../../common/runtime_types'; @@ -33,6 +34,20 @@ export const initLogEntriesHighlightsRoute = ({ framework, logEntries }: LogsSha { version: '1', validate: { request: { body: escapeHatch } }, + options: { + deprecated: { + documentationUrl: '', + severity: 'warning', + message: i18n.translate( + 'xpack.logsShared.deprecations.postLogEntriesHighlightsRoute.message', + { + defaultMessage: + 'Given the deprecation of the LogStream feature, this API will not return reliable data in upcoming versions of Kibana.', + } + ), + reason: { type: 'deprecate' }, + }, + }, }, async (requestContext, request, response) => { const payload = pipe( diff --git a/x-pack/plugins/observability_solution/logs_shared/server/routes/log_entries/summary.ts b/x-pack/plugins/observability_solution/logs_shared/server/routes/log_entries/summary.ts index 2ac889ab9ffdf..68c9d5ea0e166 100644 --- a/x-pack/plugins/observability_solution/logs_shared/server/routes/log_entries/summary.ts +++ b/x-pack/plugins/observability_solution/logs_shared/server/routes/log_entries/summary.ts @@ -12,6 +12,7 @@ import { fold } from 'fp-ts/lib/Either'; import { identity } from 'fp-ts/lib/function'; import { schema } from '@kbn/config-schema'; +import { i18n } from '@kbn/i18n'; import { logEntriesV1 } from '../../../common/http_api'; import { throwErrors } from '../../../common/runtime_types'; @@ -36,6 +37,20 @@ export const initLogEntriesSummaryRoute = ({ { version: '1', validate: { request: { body: escapeHatch } }, + options: { + deprecated: { + documentationUrl: '', + severity: 'warning', + message: i18n.translate( + 'xpack.logsShared.deprecations.postLogEntriesSummaryRoute.message', + { + defaultMessage: + 'Given the deprecation of the LogStream feature, this API will not return reliable data in upcoming versions of Kibana.', + } + ), + reason: { type: 'deprecate' }, + }, + }, }, async (requestContext, request, response) => { const payload = pipe( diff --git a/x-pack/plugins/observability_solution/logs_shared/server/routes/log_entries/summary_highlights.ts b/x-pack/plugins/observability_solution/logs_shared/server/routes/log_entries/summary_highlights.ts index b4093f1d6543b..b8f030b91b715 100644 --- a/x-pack/plugins/observability_solution/logs_shared/server/routes/log_entries/summary_highlights.ts +++ b/x-pack/plugins/observability_solution/logs_shared/server/routes/log_entries/summary_highlights.ts @@ -12,6 +12,7 @@ import { fold } from 'fp-ts/lib/Either'; import { identity } from 'fp-ts/lib/function'; import { schema } from '@kbn/config-schema'; +import { i18n } from '@kbn/i18n'; import { logEntriesV1 } from '../../../common/http_api'; import { throwErrors } from '../../../common/runtime_types'; @@ -35,6 +36,20 @@ export const initLogEntriesSummaryHighlightsRoute = ({ { version: '1', validate: { request: { body: escapeHatch } }, + options: { + deprecated: { + documentationUrl: '', + severity: 'warning', + message: i18n.translate( + 'xpack.logsShared.deprecations.postLogEntriesSummaryHighlightsRoute.message', + { + defaultMessage: + 'Given the deprecation of the LogStream feature, this API will not return reliable data in upcoming versions of Kibana.', + } + ), + reason: { type: 'deprecate' }, + }, + }, }, async (requestContext, request, response) => { const payload = pipe( diff --git a/x-pack/plugins/observability_solution/logs_shared/server/routes/log_views/get_log_view.ts b/x-pack/plugins/observability_solution/logs_shared/server/routes/log_views/get_log_view.ts index 9370c18243b51..16ca40ac2d6d8 100644 --- a/x-pack/plugins/observability_solution/logs_shared/server/routes/log_views/get_log_view.ts +++ b/x-pack/plugins/observability_solution/logs_shared/server/routes/log_views/get_log_view.ts @@ -5,6 +5,7 @@ * 2.0. */ +import { i18n } from '@kbn/i18n'; import { logViewsV1 } from '../../../common/http_api'; import { LOG_VIEW_URL } from '../../../common/http_api/log_views'; import { createValidationFunction } from '../../../common/runtime_types'; @@ -30,6 +31,17 @@ export const initGetLogViewRoute = ({ params: createValidationFunction(logViewsV1.getLogViewRequestParamsRT), }, }, + options: { + deprecated: { + documentationUrl: '', + severity: 'warning', + message: i18n.translate('xpack.logsShared.deprecations.getLogViewRoute.message', { + defaultMessage: + 'Given the deprecation of the LogStream feature, this API will not have any effect configuring upcoming versions of Kibana.', + }), + reason: { type: 'deprecate' }, + }, + }, }, async (_requestContext, request, response) => { const { logViewId } = request.params; diff --git a/x-pack/plugins/observability_solution/logs_shared/server/routes/log_views/put_log_view.ts b/x-pack/plugins/observability_solution/logs_shared/server/routes/log_views/put_log_view.ts index 95e37bff52f87..c2ba33867d067 100644 --- a/x-pack/plugins/observability_solution/logs_shared/server/routes/log_views/put_log_view.ts +++ b/x-pack/plugins/observability_solution/logs_shared/server/routes/log_views/put_log_view.ts @@ -5,6 +5,7 @@ * 2.0. */ +import { i18n } from '@kbn/i18n'; import { logViewsV1 } from '../../../common/http_api'; import { LOG_VIEW_URL } from '../../../common/http_api/log_views'; import { createValidationFunction } from '../../../common/runtime_types'; @@ -26,6 +27,17 @@ export const initPutLogViewRoute = ({ framework, getStartServices }: LogsSharedB body: createValidationFunction(logViewsV1.putLogViewRequestPayloadRT), }, }, + options: { + deprecated: { + documentationUrl: '', + severity: 'warning', + message: i18n.translate('xpack.logsShared.deprecations.putLogViewRoute.message', { + defaultMessage: + 'Given the deprecation of the LogStream feature, this API will not have any effect configuring upcoming versions of Kibana.', + }), + reason: { type: 'deprecate' }, + }, + }, }, async (_requestContext, request, response) => { const { logViewId } = request.params; diff --git a/x-pack/plugins/observability_solution/logs_shared/server/services/log_entries/log_entries_service.ts b/x-pack/plugins/observability_solution/logs_shared/server/services/log_entries/log_entries_service.ts index 61810c47ff8d2..a1cfab1c24eb1 100644 --- a/x-pack/plugins/observability_solution/logs_shared/server/services/log_entries/log_entries_service.ts +++ b/x-pack/plugins/observability_solution/logs_shared/server/services/log_entries/log_entries_service.ts @@ -22,10 +22,20 @@ export class LogEntriesService { setupDeps: LogEntriesServiceSetupDeps ) { void core.getStartServices().then(([, startDeps, selfStartDeps]) => { + /** + * @deprecated + * + * Given the deprecation of the LogStream feature, this API will not return reliable data in upcoming versions of Kibana. + */ setupDeps.data.search.registerSearchStrategy( LOG_ENTRIES_SEARCH_STRATEGY, logEntriesSearchStrategyProvider({ ...setupDeps, ...startDeps, ...selfStartDeps }) ); + /** + * @deprecated + * + * Given the deprecation of the LogStream feature, this API will not return reliable data in upcoming versions of Kibana. + */ setupDeps.data.search.registerSearchStrategy( LOG_ENTRY_SEARCH_STRATEGY, logEntrySearchStrategyProvider({ ...setupDeps, ...startDeps, ...selfStartDeps })