From 619300098713de7a32748eaa02801ac1b29fcf5e Mon Sep 17 00:00:00 2001 From: Joe Reuter Date: Tue, 18 Feb 2025 14:23:16 +0100 Subject: [PATCH 01/15] move storage adapter --- package.json | 1 + .../shared/kbn-storage-adapter}/README.md | 0 .../kbn-storage-adapter/get_schema_version.ts | 17 ++++++++++ .../shared/kbn-storage-adapter}/index.ts | 9 +++-- .../index_adapter/index.ts | 8 +++-- .../integration_tests/index.test.ts | 8 +++-- .../shared/kbn-storage-adapter/jest.config.js | 14 ++++++++ .../jest.integration.config.js | 14 ++++++++ .../shared/kbn-storage-adapter/kibana.jsonc | 9 +++++ .../shared/kbn-storage-adapter/package.json | 6 ++++ .../shared/kbn-storage-adapter/tsconfig.json | 34 +++++++++++++++++++ .../shared/kbn-storage-adapter}/types.ts | 8 +++-- tsconfig.base.json | 2 ++ .../es/storage/get_schema_version.ts | 15 -------- .../utils-server/jest.integration.config.js | 12 ------- .../server/lib/streams/assets/asset_client.ts | 2 +- .../lib/streams/assets/asset_service.ts | 2 +- .../lib/streams/assets/storage_settings.ts | 2 +- .../streams/server/lib/streams/service.ts | 7 +--- yarn.lock | 4 +++ 20 files changed, 126 insertions(+), 48 deletions(-) rename {x-pack/solutions/observability/packages/utils-server/es/storage => src/platform/packages/shared/kbn-storage-adapter}/README.md (100%) create mode 100644 src/platform/packages/shared/kbn-storage-adapter/get_schema_version.ts rename {x-pack/solutions/observability/packages/utils-server/es/storage => src/platform/packages/shared/kbn-storage-adapter}/index.ts (92%) rename {x-pack/solutions/observability/packages/utils-server/es/storage => src/platform/packages/shared/kbn-storage-adapter}/index_adapter/index.ts (97%) rename {x-pack/solutions/observability/packages/utils-server/es/storage => src/platform/packages/shared/kbn-storage-adapter}/index_adapter/integration_tests/index.test.ts (97%) create mode 100644 src/platform/packages/shared/kbn-storage-adapter/jest.config.js create mode 100644 src/platform/packages/shared/kbn-storage-adapter/jest.integration.config.js create mode 100644 src/platform/packages/shared/kbn-storage-adapter/kibana.jsonc create mode 100644 src/platform/packages/shared/kbn-storage-adapter/package.json create mode 100644 src/platform/packages/shared/kbn-storage-adapter/tsconfig.json rename {x-pack/solutions/observability/packages/utils-server/es/storage => src/platform/packages/shared/kbn-storage-adapter}/types.ts (88%) delete mode 100644 x-pack/solutions/observability/packages/utils-server/es/storage/get_schema_version.ts delete mode 100644 x-pack/solutions/observability/packages/utils-server/jest.integration.config.js diff --git a/package.json b/package.json index b81f08a5b8faf..94bacf4b4823b 100644 --- a/package.json +++ b/package.json @@ -932,6 +932,7 @@ "@kbn/status-plugin-a-plugin": "link:test/server_integration/plugins/status_plugin_a", "@kbn/status-plugin-b-plugin": "link:test/server_integration/plugins/status_plugin_b", "@kbn/std": "link:src/platform/packages/shared/kbn-std", + "@kbn/storage-adapter": "link:src/platform/packages/shared/kbn-storage-adapter", "@kbn/streams-app-plugin": "link:x-pack/solutions/observability/plugins/streams_app", "@kbn/streams-plugin": "link:x-pack/solutions/observability/plugins/streams", "@kbn/streams-schema": "link:x-pack/solutions/observability/packages/kbn-streams-schema", diff --git a/x-pack/solutions/observability/packages/utils-server/es/storage/README.md b/src/platform/packages/shared/kbn-storage-adapter/README.md similarity index 100% rename from x-pack/solutions/observability/packages/utils-server/es/storage/README.md rename to src/platform/packages/shared/kbn-storage-adapter/README.md diff --git a/src/platform/packages/shared/kbn-storage-adapter/get_schema_version.ts b/src/platform/packages/shared/kbn-storage-adapter/get_schema_version.ts new file mode 100644 index 0000000000000..5b391c66e516c --- /dev/null +++ b/src/platform/packages/shared/kbn-storage-adapter/get_schema_version.ts @@ -0,0 +1,17 @@ +/* + * 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", the "GNU Affero General Public License v3.0 only", and the "Server Side + * Public License v 1"; you may not use this file except in compliance with, at + * your election, the "Elastic License 2.0", the "GNU Affero General Public + * License v3.0 only", or the "Server Side Public License, v 1". + */ + +import stringify from 'json-stable-stringify'; +import objectHash from 'object-hash'; +import { IndexStorageSettings } from '.'; + +export function getSchemaVersion(storage: IndexStorageSettings): string { + const version = objectHash(stringify(storage.schema.properties)); + return version; +} diff --git a/x-pack/solutions/observability/packages/utils-server/es/storage/index.ts b/src/platform/packages/shared/kbn-storage-adapter/index.ts similarity index 92% rename from x-pack/solutions/observability/packages/utils-server/es/storage/index.ts rename to src/platform/packages/shared/kbn-storage-adapter/index.ts index d2051b720dfe2..bfb68d503ee61 100644 --- a/x-pack/solutions/observability/packages/utils-server/es/storage/index.ts +++ b/src/platform/packages/shared/kbn-storage-adapter/index.ts @@ -1,9 +1,12 @@ /* * 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. + * or more contributor license agreements. Licensed under the "Elastic License + * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side + * Public License v 1"; you may not use this file except in compliance with, at + * your election, the "Elastic License 2.0", the "GNU Affero General Public + * License v3.0 only", or the "Server Side Public License, v 1". */ + import type { BulkRequest, BulkResponse, diff --git a/x-pack/solutions/observability/packages/utils-server/es/storage/index_adapter/index.ts b/src/platform/packages/shared/kbn-storage-adapter/index_adapter/index.ts similarity index 97% rename from x-pack/solutions/observability/packages/utils-server/es/storage/index_adapter/index.ts rename to src/platform/packages/shared/kbn-storage-adapter/index_adapter/index.ts index 3e5b5b9a1ae18..f53596f1975e7 100644 --- a/x-pack/solutions/observability/packages/utils-server/es/storage/index_adapter/index.ts +++ b/src/platform/packages/shared/kbn-storage-adapter/index_adapter/index.ts @@ -1,8 +1,10 @@ /* * 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. + * or more contributor license agreements. Licensed under the "Elastic License + * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side + * Public License v 1"; you may not use this file except in compliance with, at + * your election, the "Elastic License 2.0", the "GNU Affero General Public + * License v3.0 only", or the "Server Side Public License, v 1". */ import type { diff --git a/x-pack/solutions/observability/packages/utils-server/es/storage/index_adapter/integration_tests/index.test.ts b/src/platform/packages/shared/kbn-storage-adapter/index_adapter/integration_tests/index.test.ts similarity index 97% rename from x-pack/solutions/observability/packages/utils-server/es/storage/index_adapter/integration_tests/index.test.ts rename to src/platform/packages/shared/kbn-storage-adapter/index_adapter/integration_tests/index.test.ts index 4b9327d4cc5c8..2bad01a9cfea5 100644 --- a/x-pack/solutions/observability/packages/utils-server/es/storage/index_adapter/integration_tests/index.test.ts +++ b/src/platform/packages/shared/kbn-storage-adapter/index_adapter/integration_tests/index.test.ts @@ -1,8 +1,10 @@ /* * 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. + * or more contributor license agreements. Licensed under the "Elastic License + * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side + * Public License v 1"; you may not use this file except in compliance with, at + * your election, the "Elastic License 2.0", the "GNU Affero General Public + * License v3.0 only", or the "Server Side Public License, v 1". */ import { diff --git a/src/platform/packages/shared/kbn-storage-adapter/jest.config.js b/src/platform/packages/shared/kbn-storage-adapter/jest.config.js new file mode 100644 index 0000000000000..f525ee104da1e --- /dev/null +++ b/src/platform/packages/shared/kbn-storage-adapter/jest.config.js @@ -0,0 +1,14 @@ +/* + * 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", the "GNU Affero General Public License v3.0 only", and the "Server Side + * Public License v 1"; you may not use this file except in compliance with, at + * your election, the "Elastic License 2.0", the "GNU Affero General Public + * License v3.0 only", or the "Server Side Public License, v 1". + */ + +module.exports = { + preset: '@kbn/test', + rootDir: '../../../../..', + roots: ['/src/platform/packages/shated/kbn-storage-adapter'], +}; diff --git a/src/platform/packages/shared/kbn-storage-adapter/jest.integration.config.js b/src/platform/packages/shared/kbn-storage-adapter/jest.integration.config.js new file mode 100644 index 0000000000000..7102763976ecb --- /dev/null +++ b/src/platform/packages/shared/kbn-storage-adapter/jest.integration.config.js @@ -0,0 +1,14 @@ +/* + * 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", the "GNU Affero General Public License v3.0 only", and the "Server Side + * Public License v 1"; you may not use this file except in compliance with, at + * your election, the "Elastic License 2.0", the "GNU Affero General Public + * License v3.0 only", or the "Server Side Public License, v 1". + */ + +module.exports = { + preset: '@kbn/test/jest_integration', + rootDir: '../../../../..', + roots: ['/src/platform/packages/shated/kbn-storage-adapter'], +}; diff --git a/src/platform/packages/shared/kbn-storage-adapter/kibana.jsonc b/src/platform/packages/shared/kbn-storage-adapter/kibana.jsonc new file mode 100644 index 0000000000000..7cbd23ae88225 --- /dev/null +++ b/src/platform/packages/shared/kbn-storage-adapter/kibana.jsonc @@ -0,0 +1,9 @@ +{ + "type": "shared-server", + "id": "@kbn/storage-adapter", + "owner": [ + "@elastic/observability-ui" + ], + "group": "platform", + "visibility": "shared" +} diff --git a/src/platform/packages/shared/kbn-storage-adapter/package.json b/src/platform/packages/shared/kbn-storage-adapter/package.json new file mode 100644 index 0000000000000..e426b5cea9781 --- /dev/null +++ b/src/platform/packages/shared/kbn-storage-adapter/package.json @@ -0,0 +1,6 @@ +{ + "name": "@kbn/storage-adapter", + "private": true, + "version": "1.0.0", + "license": "Elastic License 2.0" +} diff --git a/src/platform/packages/shared/kbn-storage-adapter/tsconfig.json b/src/platform/packages/shared/kbn-storage-adapter/tsconfig.json new file mode 100644 index 0000000000000..4546c8c069a95 --- /dev/null +++ b/src/platform/packages/shared/kbn-storage-adapter/tsconfig.json @@ -0,0 +1,34 @@ +{ + "extends": "../../../../../tsconfig.base.json", + "compilerOptions": { + "outDir": "target/types", + "types": [ + "jest", + "node", + "react" + ] + }, + "include": [ + "**/*.ts", + "**/*.tsx", + ], + "exclude": [ + "target/**/*" + ], + "kbn_references": [ + "@kbn/core", + "@kbn/es-types", + "@kbn/apm-utils", + "@kbn/es-query", + "@kbn/observability-utils-common", + "@kbn/alerting-plugin", + "@kbn/rule-registry-plugin", + "@kbn/rule-data-utils", + "@kbn/aiops-log-pattern-analysis", + "@kbn/calculate-auto", + "@kbn/utility-types", + "@kbn/task-manager-plugin", + "@kbn/es-errors", + "@kbn/core-test-helpers-kbn-server", + ] +} diff --git a/x-pack/solutions/observability/packages/utils-server/es/storage/types.ts b/src/platform/packages/shared/kbn-storage-adapter/types.ts similarity index 88% rename from x-pack/solutions/observability/packages/utils-server/es/storage/types.ts rename to src/platform/packages/shared/kbn-storage-adapter/types.ts index 08d8fecff3cf0..3ef39cb390645 100644 --- a/x-pack/solutions/observability/packages/utils-server/es/storage/types.ts +++ b/src/platform/packages/shared/kbn-storage-adapter/types.ts @@ -1,8 +1,10 @@ /* * 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. + * or more contributor license agreements. Licensed under the "Elastic License + * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side + * Public License v 1"; you may not use this file except in compliance with, at + * your election, the "Elastic License 2.0", the "GNU Affero General Public + * License v3.0 only", or the "Server Side Public License, v 1". */ import { MappingObjectProperty, MappingProperty } from '@elastic/elasticsearch/lib/api/types'; diff --git a/tsconfig.base.json b/tsconfig.base.json index 2515856bd6ca8..1ce784eaf542b 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -1894,6 +1894,8 @@ "@kbn/std/*": ["src/platform/packages/shared/kbn-std/*"], "@kbn/stdio-dev-helpers": ["packages/kbn-stdio-dev-helpers"], "@kbn/stdio-dev-helpers/*": ["packages/kbn-stdio-dev-helpers/*"], + "@kbn/storage-adapter": ["src/platform/packages/shared/kbn-storage-adapter"], + "@kbn/storage-adapter/*": ["src/platform/packages/shared/kbn-storage-adapter/*"], "@kbn/storybook": ["packages/kbn-storybook"], "@kbn/storybook/*": ["packages/kbn-storybook/*"], "@kbn/streams-app-plugin": ["x-pack/solutions/observability/plugins/streams_app"], diff --git a/x-pack/solutions/observability/packages/utils-server/es/storage/get_schema_version.ts b/x-pack/solutions/observability/packages/utils-server/es/storage/get_schema_version.ts deleted file mode 100644 index 0be986c168cba..0000000000000 --- a/x-pack/solutions/observability/packages/utils-server/es/storage/get_schema_version.ts +++ /dev/null @@ -1,15 +0,0 @@ -/* - * 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 stringify from 'json-stable-stringify'; -import objectHash from 'object-hash'; -import { IndexStorageSettings } from '.'; - -export function getSchemaVersion(storage: IndexStorageSettings): string { - const version = objectHash(stringify(storage.schema.properties)); - return version; -} diff --git a/x-pack/solutions/observability/packages/utils-server/jest.integration.config.js b/x-pack/solutions/observability/packages/utils-server/jest.integration.config.js deleted file mode 100644 index bc0723cc66c2e..0000000000000 --- a/x-pack/solutions/observability/packages/utils-server/jest.integration.config.js +++ /dev/null @@ -1,12 +0,0 @@ -/* - * 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. - */ - -module.exports = { - preset: '@kbn/test/jest_integration', - rootDir: '../../../../..', - roots: ['/x-pack/solutions/observability/packages/utils-server'], -}; diff --git a/x-pack/solutions/observability/plugins/streams/server/lib/streams/assets/asset_client.ts b/x-pack/solutions/observability/plugins/streams/server/lib/streams/assets/asset_client.ts index 2406c56c809fe..a1abe9f2bd2cd 100644 --- a/x-pack/solutions/observability/plugins/streams/server/lib/streams/assets/asset_client.ts +++ b/x-pack/solutions/observability/plugins/streams/server/lib/streams/assets/asset_client.ts @@ -8,7 +8,7 @@ import { SanitizedRule } from '@kbn/alerting-plugin/common'; import { RulesClient } from '@kbn/alerting-plugin/server'; import { SavedObject, SavedObjectsClientContract } from '@kbn/core/server'; import { termQuery } from '@kbn/observability-utils-server/es/queries/term_query'; -import { IStorageClient } from '@kbn/observability-utils-server/es/storage'; +import { IStorageClient } from '@kbn/storage-adapter'; import { keyBy } from 'lodash'; import objectHash from 'object-hash'; import pLimit from 'p-limit'; diff --git a/x-pack/solutions/observability/plugins/streams/server/lib/streams/assets/asset_service.ts b/x-pack/solutions/observability/plugins/streams/server/lib/streams/assets/asset_service.ts index 47bd57433b9d8..1115e2314a247 100644 --- a/x-pack/solutions/observability/plugins/streams/server/lib/streams/assets/asset_service.ts +++ b/x-pack/solutions/observability/plugins/streams/server/lib/streams/assets/asset_service.ts @@ -6,7 +6,7 @@ */ import { CoreSetup, KibanaRequest, Logger } from '@kbn/core/server'; -import { StorageIndexAdapter } from '@kbn/observability-utils-server/es/storage'; +import { StorageIndexAdapter } from '@kbn/storage-adapter'; import { StreamsPluginStartDependencies } from '../../../types'; import { AssetClient, StoredAssetLink } from './asset_client'; import { AssetStorageSettings, assetStorageSettings } from './storage_settings'; diff --git a/x-pack/solutions/observability/plugins/streams/server/lib/streams/assets/storage_settings.ts b/x-pack/solutions/observability/plugins/streams/server/lib/streams/assets/storage_settings.ts index d5c5145c2137d..2d9515ddd281f 100644 --- a/x-pack/solutions/observability/plugins/streams/server/lib/streams/assets/storage_settings.ts +++ b/x-pack/solutions/observability/plugins/streams/server/lib/streams/assets/storage_settings.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { IndexStorageSettings, types } from '@kbn/observability-utils-server/es/storage'; +import { IndexStorageSettings, types } from '@kbn/storage-adapter'; import { ASSET_ASSET_ID, ASSET_ENTITY_ID, ASSET_ENTITY_TYPE, ASSET_TYPE } from './fields'; export const assetStorageSettings = { diff --git a/x-pack/solutions/observability/plugins/streams/server/lib/streams/service.ts b/x-pack/solutions/observability/plugins/streams/server/lib/streams/service.ts index b79159d0cfaa3..bd39469d1b040 100644 --- a/x-pack/solutions/observability/plugins/streams/server/lib/streams/service.ts +++ b/x-pack/solutions/observability/plugins/streams/server/lib/streams/service.ts @@ -6,12 +6,7 @@ */ import type { CoreSetup, KibanaRequest, Logger } from '@kbn/core/server'; -import { - IStorageClient, - StorageIndexAdapter, - StorageSettings, - types, -} from '@kbn/observability-utils-server/es/storage'; +import { IStorageClient, StorageIndexAdapter, StorageSettings, types } from '@kbn/storage-adapter'; import { StreamDefinition } from '@kbn/streams-schema'; import type { StreamsPluginStartDependencies } from '../../types'; import { StreamsClient } from './client'; diff --git a/yarn.lock b/yarn.lock index 86b8417af4ea0..6413aef67c73b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7657,6 +7657,10 @@ version "0.0.0" uid "" +"@kbn/storage-adapter@link:src/platform/packages/shared/kbn-storage-adapter": + version "0.0.0" + uid "" + "@kbn/storybook@link:packages/kbn-storybook": version "0.0.0" uid "" From 7569e7d14ddaaf229c9cce8c19bba53188d4db46 Mon Sep 17 00:00:00 2001 From: Joe Reuter Date: Tue, 18 Feb 2025 14:24:07 +0100 Subject: [PATCH 02/15] fix codeowners --- .github/CODEOWNERS | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 3b0c9db5810fd..f2f7c02e692b9 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -531,6 +531,7 @@ src/platform/packages/shared/kbn-sse-utils @elastic/obs-knowledge-team src/platform/packages/shared/kbn-sse-utils-client @elastic/obs-knowledge-team src/platform/packages/shared/kbn-sse-utils-server @elastic/obs-knowledge-team src/platform/packages/shared/kbn-std @elastic/kibana-core +src/platform/packages/shared/kbn-storage-adapter @elastic/observability-ui src/platform/packages/shared/kbn-timerange @elastic/obs-ux-logs-team src/platform/packages/shared/kbn-triggers-actions-ui-types @elastic/response-ops src/platform/packages/shared/kbn-try-in-console @elastic/search-kibana From 9338421bdf0548d6efa47713aea0d3c3eead7003 Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Tue, 18 Feb 2025 13:36:34 +0000 Subject: [PATCH 03/15] [CI] Auto-commit changed files from 'node scripts/lint_packages --fix' --- src/platform/packages/shared/kbn-storage-adapter/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platform/packages/shared/kbn-storage-adapter/package.json b/src/platform/packages/shared/kbn-storage-adapter/package.json index e426b5cea9781..168be2e80833c 100644 --- a/src/platform/packages/shared/kbn-storage-adapter/package.json +++ b/src/platform/packages/shared/kbn-storage-adapter/package.json @@ -2,5 +2,5 @@ "name": "@kbn/storage-adapter", "private": true, "version": "1.0.0", - "license": "Elastic License 2.0" + "license": "Elastic License 2.0 OR AGPL-3.0-only OR SSPL-1.0" } From 4e3187b9d1c697c6c541b50854e21c6e17777c9c Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Tue, 18 Feb 2025 13:37:12 +0000 Subject: [PATCH 04/15] [CI] Auto-commit changed files from 'node scripts/notice' --- .../packages/shared/kbn-storage-adapter/tsconfig.json | 10 ---------- .../observability/packages/utils-server/tsconfig.json | 2 -- .../observability/plugins/streams/tsconfig.json | 3 ++- 3 files changed, 2 insertions(+), 13 deletions(-) diff --git a/src/platform/packages/shared/kbn-storage-adapter/tsconfig.json b/src/platform/packages/shared/kbn-storage-adapter/tsconfig.json index 4546c8c069a95..3e324dcf4a8a0 100644 --- a/src/platform/packages/shared/kbn-storage-adapter/tsconfig.json +++ b/src/platform/packages/shared/kbn-storage-adapter/tsconfig.json @@ -18,16 +18,6 @@ "kbn_references": [ "@kbn/core", "@kbn/es-types", - "@kbn/apm-utils", - "@kbn/es-query", - "@kbn/observability-utils-common", - "@kbn/alerting-plugin", - "@kbn/rule-registry-plugin", - "@kbn/rule-data-utils", - "@kbn/aiops-log-pattern-analysis", - "@kbn/calculate-auto", - "@kbn/utility-types", - "@kbn/task-manager-plugin", "@kbn/es-errors", "@kbn/core-test-helpers-kbn-server", ] diff --git a/x-pack/solutions/observability/packages/utils-server/tsconfig.json b/x-pack/solutions/observability/packages/utils-server/tsconfig.json index 4546c8c069a95..33d7e75322f00 100644 --- a/x-pack/solutions/observability/packages/utils-server/tsconfig.json +++ b/x-pack/solutions/observability/packages/utils-server/tsconfig.json @@ -28,7 +28,5 @@ "@kbn/calculate-auto", "@kbn/utility-types", "@kbn/task-manager-plugin", - "@kbn/es-errors", - "@kbn/core-test-helpers-kbn-server", ] } diff --git a/x-pack/solutions/observability/plugins/streams/tsconfig.json b/x-pack/solutions/observability/plugins/streams/tsconfig.json index 748e722f66f9f..7118e33758af7 100644 --- a/x-pack/solutions/observability/plugins/streams/tsconfig.json +++ b/x-pack/solutions/observability/plugins/streams/tsconfig.json @@ -36,6 +36,7 @@ "@kbn/safer-lodash-set", "@kbn/streams-schema", "@kbn/es-errors", - "@kbn/server-route-repository-utils" + "@kbn/server-route-repository-utils", + "@kbn/storage-adapter" ] } From 9ec5f161570c7d3c12c99346e78eb0c985cf9cfb Mon Sep 17 00:00:00 2001 From: Joe Reuter Date: Tue, 18 Feb 2025 14:49:04 +0100 Subject: [PATCH 05/15] move more over --- package.json | 1 + .../shared/kbn-storage-adapter/index.ts | 2 +- .../{ => src}/get_schema_version.ts | 2 +- .../{ => src}/index_adapter/index.ts | 4 +-- .../integration_tests/index.test.ts | 2 +- .../shared/kbn-traced-es-client/index.ts | 10 ++++++ .../kbn-traced-es-client/jest.config.js | 14 ++++++++ .../shared/kbn-traced-es-client/kibana.jsonc | 9 +++++ .../shared/kbn-traced-es-client/package.json | 6 ++++ .../src}/create_observability_es_client.ts | 10 +++--- .../src}/esql_result_to_plain_objects.test.ts | 8 +++-- .../src}/esql_result_to_plain_objects.ts | 8 +++-- .../shared/kbn-traced-es-client/tsconfig.json | 34 +++++++++++++++++++ tsconfig.base.json | 2 ++ .../run_root_cause_analysis.ts | 2 +- .../analyze_fetched_related_entities.ts | 2 +- .../tasks/find_related_entities/index.ts | 2 +- .../tasks/investigate_entity/index.ts | 2 +- .../root_cause_analysis/types.ts | 2 +- .../entities/get_data_stream_types.test.ts | 2 +- .../routes/entities/get_data_stream_types.ts | 2 +- .../infra/server/routes/entities/index.ts | 2 +- .../server/routes/rca/route.ts | 2 +- ...bservability_ai_assistant_app_es_client.ts | 2 +- .../streams/server/routes/esql/route.ts | 5 +-- .../esql_chart/controlled_esql_chart.tsx | 2 +- .../public/util/esql_result_to_timeseries.ts | 2 +- yarn.lock | 4 +++ 28 files changed, 114 insertions(+), 31 deletions(-) rename src/platform/packages/shared/kbn-storage-adapter/{ => src}/get_schema_version.ts (94%) rename src/platform/packages/shared/kbn-storage-adapter/{ => src}/index_adapter/index.ts (99%) rename src/platform/packages/shared/kbn-storage-adapter/{ => src}/index_adapter/integration_tests/index.test.ts (99%) create mode 100644 src/platform/packages/shared/kbn-traced-es-client/index.ts create mode 100644 src/platform/packages/shared/kbn-traced-es-client/jest.config.js create mode 100644 src/platform/packages/shared/kbn-traced-es-client/kibana.jsonc create mode 100644 src/platform/packages/shared/kbn-traced-es-client/package.json rename {x-pack/solutions/observability/packages/utils-server/es/client => src/platform/packages/shared/kbn-traced-es-client/src}/create_observability_es_client.ts (93%) rename {x-pack/solutions/observability/packages/utils-server/es => src/platform/packages/shared/kbn-traced-es-client/src}/esql_result_to_plain_objects.test.ts (75%) rename {x-pack/solutions/observability/packages/utils-server/es => src/platform/packages/shared/kbn-traced-es-client/src}/esql_result_to_plain_objects.ts (63%) create mode 100644 src/platform/packages/shared/kbn-traced-es-client/tsconfig.json diff --git a/package.json b/package.json index 94bacf4b4823b..4d48959bafedb 100644 --- a/package.json +++ b/package.json @@ -954,6 +954,7 @@ "@kbn/timelion-grammar": "link:src/platform/packages/private/kbn-timelion-grammar", "@kbn/timerange": "link:src/platform/packages/shared/kbn-timerange", "@kbn/tinymath": "link:src/platform/packages/private/kbn-tinymath", + "@kbn/traced-es-client": "link:src/platform/packages/shared/kbn-traced-es-client", "@kbn/transform-plugin": "link:x-pack/platform/plugins/private/transform", "@kbn/translations-plugin": "link:x-pack/platform/plugins/private/translations", "@kbn/transpose-utils": "link:src/platform/packages/private/kbn-transpose-utils", diff --git a/src/platform/packages/shared/kbn-storage-adapter/index.ts b/src/platform/packages/shared/kbn-storage-adapter/index.ts index bfb68d503ee61..0b35732928f57 100644 --- a/src/platform/packages/shared/kbn-storage-adapter/index.ts +++ b/src/platform/packages/shared/kbn-storage-adapter/index.ts @@ -154,6 +154,6 @@ export type StorageDocumentOf = Storag properties: TStorageSettings['schema']['properties']; }> & { _id: string }; -export { StorageIndexAdapter } from './index_adapter'; +export { StorageIndexAdapter } from './src/index_adapter'; export { types } from './types'; diff --git a/src/platform/packages/shared/kbn-storage-adapter/get_schema_version.ts b/src/platform/packages/shared/kbn-storage-adapter/src/get_schema_version.ts similarity index 94% rename from src/platform/packages/shared/kbn-storage-adapter/get_schema_version.ts rename to src/platform/packages/shared/kbn-storage-adapter/src/get_schema_version.ts index 5b391c66e516c..461876dc593a7 100644 --- a/src/platform/packages/shared/kbn-storage-adapter/get_schema_version.ts +++ b/src/platform/packages/shared/kbn-storage-adapter/src/get_schema_version.ts @@ -9,7 +9,7 @@ import stringify from 'json-stable-stringify'; import objectHash from 'object-hash'; -import { IndexStorageSettings } from '.'; +import { IndexStorageSettings } from '..'; export function getSchemaVersion(storage: IndexStorageSettings): string { const version = objectHash(stringify(storage.schema.properties)); diff --git a/src/platform/packages/shared/kbn-storage-adapter/index_adapter/index.ts b/src/platform/packages/shared/kbn-storage-adapter/src/index_adapter/index.ts similarity index 99% rename from src/platform/packages/shared/kbn-storage-adapter/index_adapter/index.ts rename to src/platform/packages/shared/kbn-storage-adapter/src/index_adapter/index.ts index f53596f1975e7..28b4d4c76a2ea 100644 --- a/src/platform/packages/shared/kbn-storage-adapter/index_adapter/index.ts +++ b/src/platform/packages/shared/kbn-storage-adapter/src/index_adapter/index.ts @@ -37,9 +37,9 @@ import { StorageClientCleanResponse, ApplicationDocument, InternalIStorageClient, -} from '..'; +} from '../..'; import { getSchemaVersion } from '../get_schema_version'; -import { StorageMappingProperty } from '../types'; +import { StorageMappingProperty } from '../../types'; function getAliasName(name: string) { return name; diff --git a/src/platform/packages/shared/kbn-storage-adapter/index_adapter/integration_tests/index.test.ts b/src/platform/packages/shared/kbn-storage-adapter/src/index_adapter/integration_tests/index.test.ts similarity index 99% rename from src/platform/packages/shared/kbn-storage-adapter/index_adapter/integration_tests/index.test.ts rename to src/platform/packages/shared/kbn-storage-adapter/src/index_adapter/integration_tests/index.test.ts index 2bad01a9cfea5..f5c637bc19db4 100644 --- a/src/platform/packages/shared/kbn-storage-adapter/index_adapter/integration_tests/index.test.ts +++ b/src/platform/packages/shared/kbn-storage-adapter/src/index_adapter/integration_tests/index.test.ts @@ -18,7 +18,7 @@ import { StorageClientIndexResponse, StorageIndexAdapter, type StorageSettings, -} from '../..'; +} from '../../..'; import type { ElasticsearchClient, Logger } from '@kbn/core/server'; import { httpServerMock } from '@kbn/core/server/mocks'; import * as getSchemaVersionModule from '../../get_schema_version'; diff --git a/src/platform/packages/shared/kbn-traced-es-client/index.ts b/src/platform/packages/shared/kbn-traced-es-client/index.ts new file mode 100644 index 0000000000000..6365216d0ee9a --- /dev/null +++ b/src/platform/packages/shared/kbn-traced-es-client/index.ts @@ -0,0 +1,10 @@ +/* + * 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", the "GNU Affero General Public License v3.0 only", and the "Server Side + * Public License v 1"; you may not use this file except in compliance with, at + * your election, the "Elastic License 2.0", the "GNU Affero General Public + * License v3.0 only", or the "Server Side Public License, v 1". + */ + +export * from './src/create_observability_es_client'; diff --git a/src/platform/packages/shared/kbn-traced-es-client/jest.config.js b/src/platform/packages/shared/kbn-traced-es-client/jest.config.js new file mode 100644 index 0000000000000..7f1eeda7c16ff --- /dev/null +++ b/src/platform/packages/shared/kbn-traced-es-client/jest.config.js @@ -0,0 +1,14 @@ +/* + * 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", the "GNU Affero General Public License v3.0 only", and the "Server Side + * Public License v 1"; you may not use this file except in compliance with, at + * your election, the "Elastic License 2.0", the "GNU Affero General Public + * License v3.0 only", or the "Server Side Public License, v 1". + */ + +module.exports = { + preset: '@kbn/test', + rootDir: '../../../../..', + roots: ['/src/platform/packages/shared/kbn-traced-es-client'], +}; diff --git a/src/platform/packages/shared/kbn-traced-es-client/kibana.jsonc b/src/platform/packages/shared/kbn-traced-es-client/kibana.jsonc new file mode 100644 index 0000000000000..eb88c4d3ef3d9 --- /dev/null +++ b/src/platform/packages/shared/kbn-traced-es-client/kibana.jsonc @@ -0,0 +1,9 @@ +{ + "type": "shared-server", + "id": "@kbn/traced-es-client", + "owner": [ + "@elastic/observability-ui" + ], + "group": "platform", + "visibility": "shared" +} diff --git a/src/platform/packages/shared/kbn-traced-es-client/package.json b/src/platform/packages/shared/kbn-traced-es-client/package.json new file mode 100644 index 0000000000000..677d5f5063122 --- /dev/null +++ b/src/platform/packages/shared/kbn-traced-es-client/package.json @@ -0,0 +1,6 @@ +{ + "name": "@kbn/traced-es-client", + "private": true, + "version": "1.0.0", + "license": "Elastic License 2.0 OR AGPL-3.0-only OR SSPL-1.0" +} diff --git a/x-pack/solutions/observability/packages/utils-server/es/client/create_observability_es_client.ts b/src/platform/packages/shared/kbn-traced-es-client/src/create_observability_es_client.ts similarity index 93% rename from x-pack/solutions/observability/packages/utils-server/es/client/create_observability_es_client.ts rename to src/platform/packages/shared/kbn-traced-es-client/src/create_observability_es_client.ts index 7731d72ffd0fe..ca793db8a1080 100644 --- a/x-pack/solutions/observability/packages/utils-server/es/client/create_observability_es_client.ts +++ b/src/platform/packages/shared/kbn-traced-es-client/src/create_observability_es_client.ts @@ -1,8 +1,10 @@ /* * 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. + * or more contributor license agreements. Licensed under the "Elastic License + * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side + * Public License v 1"; you may not use this file except in compliance with, at + * your election, the "Elastic License 2.0", the "GNU Affero General Public + * License v3.0 only", or the "Server Side Public License, v 1". */ import type { @@ -19,7 +21,7 @@ import type { ESSearchRequest, InferSearchResponseOf } from '@kbn/es-types'; import { Required, ValuesType } from 'utility-types'; import { DedotObject } from '@kbn/utility-types'; import { unflattenObject } from '@kbn/task-manager-plugin/server/metrics/lib'; -import { esqlResultToPlainObjects } from '../esql_result_to_plain_objects'; +import { esqlResultToPlainObjects } from './esql_result_to_plain_objects'; type SearchRequest = ESSearchRequest & { index: string | string[]; diff --git a/x-pack/solutions/observability/packages/utils-server/es/esql_result_to_plain_objects.test.ts b/src/platform/packages/shared/kbn-traced-es-client/src/esql_result_to_plain_objects.test.ts similarity index 75% rename from x-pack/solutions/observability/packages/utils-server/es/esql_result_to_plain_objects.test.ts rename to src/platform/packages/shared/kbn-traced-es-client/src/esql_result_to_plain_objects.test.ts index 55d77368cfdfb..ec8f47bf7ed4e 100644 --- a/x-pack/solutions/observability/packages/utils-server/es/esql_result_to_plain_objects.test.ts +++ b/src/platform/packages/shared/kbn-traced-es-client/src/esql_result_to_plain_objects.test.ts @@ -1,8 +1,10 @@ /* * 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. + * or more contributor license agreements. Licensed under the "Elastic License + * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side + * Public License v 1"; you may not use this file except in compliance with, at + * your election, the "Elastic License 2.0", the "GNU Affero General Public + * License v3.0 only", or the "Server Side Public License, v 1". */ import type { ESQLSearchResponse } from '@kbn/es-types'; diff --git a/x-pack/solutions/observability/packages/utils-server/es/esql_result_to_plain_objects.ts b/src/platform/packages/shared/kbn-traced-es-client/src/esql_result_to_plain_objects.ts similarity index 63% rename from x-pack/solutions/observability/packages/utils-server/es/esql_result_to_plain_objects.ts rename to src/platform/packages/shared/kbn-traced-es-client/src/esql_result_to_plain_objects.ts index 53f54b608ca35..65f936ceacf9a 100644 --- a/x-pack/solutions/observability/packages/utils-server/es/esql_result_to_plain_objects.ts +++ b/src/platform/packages/shared/kbn-traced-es-client/src/esql_result_to_plain_objects.ts @@ -1,8 +1,10 @@ /* * 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. + * or more contributor license agreements. Licensed under the "Elastic License + * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side + * Public License v 1"; you may not use this file except in compliance with, at + * your election, the "Elastic License 2.0", the "GNU Affero General Public + * License v3.0 only", or the "Server Side Public License, v 1". */ import type { ESQLSearchResponse } from '@kbn/es-types'; diff --git a/src/platform/packages/shared/kbn-traced-es-client/tsconfig.json b/src/platform/packages/shared/kbn-traced-es-client/tsconfig.json new file mode 100644 index 0000000000000..4546c8c069a95 --- /dev/null +++ b/src/platform/packages/shared/kbn-traced-es-client/tsconfig.json @@ -0,0 +1,34 @@ +{ + "extends": "../../../../../tsconfig.base.json", + "compilerOptions": { + "outDir": "target/types", + "types": [ + "jest", + "node", + "react" + ] + }, + "include": [ + "**/*.ts", + "**/*.tsx", + ], + "exclude": [ + "target/**/*" + ], + "kbn_references": [ + "@kbn/core", + "@kbn/es-types", + "@kbn/apm-utils", + "@kbn/es-query", + "@kbn/observability-utils-common", + "@kbn/alerting-plugin", + "@kbn/rule-registry-plugin", + "@kbn/rule-data-utils", + "@kbn/aiops-log-pattern-analysis", + "@kbn/calculate-auto", + "@kbn/utility-types", + "@kbn/task-manager-plugin", + "@kbn/es-errors", + "@kbn/core-test-helpers-kbn-server", + ] +} diff --git a/tsconfig.base.json b/tsconfig.base.json index 1ce784eaf542b..3deb70343ccfd 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -1966,6 +1966,8 @@ "@kbn/tinymath/*": ["src/platform/packages/private/kbn-tinymath/*"], "@kbn/tooling-log": ["packages/kbn-tooling-log"], "@kbn/tooling-log/*": ["packages/kbn-tooling-log/*"], + "@kbn/traced-es-client": ["src/platform/packages/shared/kbn-traced-es-client"], + "@kbn/traced-es-client/*": ["src/platform/packages/shared/kbn-traced-es-client/*"], "@kbn/transform-plugin": ["x-pack/platform/plugins/private/transform"], "@kbn/transform-plugin/*": ["x-pack/platform/plugins/private/transform/*"], "@kbn/translations-plugin": ["x-pack/platform/plugins/private/translations"], diff --git a/x-pack/solutions/observability/packages/observability-ai/observability-ai-server/root_cause_analysis/run_root_cause_analysis.ts b/x-pack/solutions/observability/packages/observability-ai/observability-ai-server/root_cause_analysis/run_root_cause_analysis.ts index 94b14b4f3d12f..0c44b76ca0b94 100644 --- a/x-pack/solutions/observability/packages/observability-ai/observability-ai-server/root_cause_analysis/run_root_cause_analysis.ts +++ b/x-pack/solutions/observability/packages/observability-ai/observability-ai-server/root_cause_analysis/run_root_cause_analysis.ts @@ -15,7 +15,7 @@ import { findLast, pick } from 'lodash'; import moment from 'moment'; import { catchError, filter, from, map, mergeMap, Observable, of, switchMap } from 'rxjs'; import { ObservabilityAIAssistantClient } from '@kbn/observability-ai-assistant-plugin/server'; -import { ObservabilityElasticsearchClient } from '@kbn/observability-utils-server/es/client/create_observability_es_client'; +import { ObservabilityElasticsearchClient } from '@kbn/traced-es-client'; import { RCA_END_PROCESS_TOOL_NAME, RCA_INVESTIGATE_ENTITY_TOOL_NAME, diff --git a/x-pack/solutions/observability/packages/observability-ai/observability-ai-server/root_cause_analysis/tasks/find_related_entities/analyze_fetched_related_entities.ts b/x-pack/solutions/observability/packages/observability-ai/observability-ai-server/root_cause_analysis/tasks/find_related_entities/analyze_fetched_related_entities.ts index 708ae462260f5..d625bb3fb12cd 100644 --- a/x-pack/solutions/observability/packages/observability-ai/observability-ai-server/root_cause_analysis/tasks/find_related_entities/analyze_fetched_related_entities.ts +++ b/x-pack/solutions/observability/packages/observability-ai/observability-ai-server/root_cause_analysis/tasks/find_related_entities/analyze_fetched_related_entities.ts @@ -15,7 +15,7 @@ import { import { sortAndTruncateAnalyzedFields } from '@kbn/observability-utils-common/llm/log_analysis/sort_and_truncate_analyzed_fields'; import { analyzeDocuments } from '@kbn/observability-utils-server/entities/analyze_documents'; import { FieldPatternResultWithChanges } from '@kbn/observability-utils-server/entities/get_log_patterns'; -import { ObservabilityElasticsearchClient } from '@kbn/observability-utils-server/es/client/create_observability_es_client'; +import { ObservabilityElasticsearchClient } from '@kbn/traced-es-client'; import { kqlQuery } from '@kbn/observability-utils-server/es/queries/kql_query'; import { rangeQuery } from '@kbn/observability-utils-server/es/queries/range_query'; import { chunk, isEmpty, isEqual } from 'lodash'; diff --git a/x-pack/solutions/observability/packages/observability-ai/observability-ai-server/root_cause_analysis/tasks/find_related_entities/index.ts b/x-pack/solutions/observability/packages/observability-ai/observability-ai-server/root_cause_analysis/tasks/find_related_entities/index.ts index 05392db2d502c..54117d9af4614 100644 --- a/x-pack/solutions/observability/packages/observability-ai/observability-ai-server/root_cause_analysis/tasks/find_related_entities/index.ts +++ b/x-pack/solutions/observability/packages/observability-ai/observability-ai-server/root_cause_analysis/tasks/find_related_entities/index.ts @@ -11,7 +11,7 @@ import { DocumentAnalysis, TruncatedDocumentAnalysis, } from '@kbn/observability-utils-common/llm/log_analysis/document_analysis'; -import { ObservabilityElasticsearchClient } from '@kbn/observability-utils-server/es/client/create_observability_es_client'; +import { ObservabilityElasticsearchClient } from '@kbn/traced-es-client'; import { FieldPatternResultWithChanges } from '@kbn/observability-utils-server/entities/get_log_patterns'; import { analyzeFetchedRelatedEntities, diff --git a/x-pack/solutions/observability/packages/observability-ai/observability-ai-server/root_cause_analysis/tasks/investigate_entity/index.ts b/x-pack/solutions/observability/packages/observability-ai/observability-ai-server/root_cause_analysis/tasks/investigate_entity/index.ts index 1e9ae7147211b..8a9687e0ae852 100644 --- a/x-pack/solutions/observability/packages/observability-ai/observability-ai-server/root_cause_analysis/tasks/investigate_entity/index.ts +++ b/x-pack/solutions/observability/packages/observability-ai/observability-ai-server/root_cause_analysis/tasks/investigate_entity/index.ts @@ -11,7 +11,7 @@ import { analyzeDocuments } from '@kbn/observability-utils-server/entities/analy import { getDataStreamsForEntity } from '@kbn/observability-utils-server/entities/get_data_streams_for_entity'; import { getAlertsForEntity } from '@kbn/observability-utils-server/entities/signals/get_alerts_for_entity'; import { getSlosForEntity } from '@kbn/observability-utils-server/entities/signals/get_slos_for_entity'; -import { ObservabilityElasticsearchClient } from '@kbn/observability-utils-server/es/client/create_observability_es_client'; +import { ObservabilityElasticsearchClient } from '@kbn/traced-es-client'; import { RootCauseAnalysisContext } from '../../types'; import { stringifySummaries } from '../../util/stringify_summaries'; import { analyzeLogPatterns } from '../analyze_log_patterns'; diff --git a/x-pack/solutions/observability/packages/observability-ai/observability-ai-server/root_cause_analysis/types.ts b/x-pack/solutions/observability/packages/observability-ai/observability-ai-server/root_cause_analysis/types.ts index 6b6fa1886309c..814ab949d5af6 100644 --- a/x-pack/solutions/observability/packages/observability-ai/observability-ai-server/root_cause_analysis/types.ts +++ b/x-pack/solutions/observability/packages/observability-ai/observability-ai-server/root_cause_analysis/types.ts @@ -17,7 +17,7 @@ import { Logger } from '@kbn/logging'; import { AlertsClient } from '@kbn/rule-registry-plugin/server'; import { RulesClient } from '@kbn/alerting-plugin/server'; import { ObservabilityAIAssistantClient } from '@kbn/observability-ai-assistant-plugin/server'; -import { ObservabilityElasticsearchClient } from '@kbn/observability-utils-server/es/client/create_observability_es_client'; +import { ObservabilityElasticsearchClient } from '@kbn/traced-es-client'; import { RCA_END_PROCESS_TOOL_NAME, RCA_INVESTIGATE_ENTITY_TOOL_NAME, diff --git a/x-pack/solutions/observability/plugins/infra/server/routes/entities/get_data_stream_types.test.ts b/x-pack/solutions/observability/plugins/infra/server/routes/entities/get_data_stream_types.test.ts index 4879d29e156ca..2570dbb3d8d7b 100644 --- a/x-pack/solutions/observability/plugins/infra/server/routes/entities/get_data_stream_types.test.ts +++ b/x-pack/solutions/observability/plugins/infra/server/routes/entities/get_data_stream_types.test.ts @@ -4,7 +4,7 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ -import type { ObservabilityElasticsearchClient } from '@kbn/observability-utils-server/es/client/create_observability_es_client'; +import type { ObservabilityElasticsearchClient } from '@kbn/traced-es-client'; import { type EntityClient } from '@kbn/entityManager-plugin/server/lib/entity_client'; import { type InfraMetricsClient } from '../../lib/helpers/get_infra_metrics_client'; import { getDataStreamTypes } from './get_data_stream_types'; diff --git a/x-pack/solutions/observability/plugins/infra/server/routes/entities/get_data_stream_types.ts b/x-pack/solutions/observability/plugins/infra/server/routes/entities/get_data_stream_types.ts index bdd592fda201a..274ac9049021e 100644 --- a/x-pack/solutions/observability/plugins/infra/server/routes/entities/get_data_stream_types.ts +++ b/x-pack/solutions/observability/plugins/infra/server/routes/entities/get_data_stream_types.ts @@ -9,7 +9,7 @@ import { type EntityClient } from '@kbn/entityManager-plugin/server/lib/entity_c import type { InventoryItemType } from '@kbn/metrics-data-access-plugin/common'; import { findInventoryFields } from '@kbn/metrics-data-access-plugin/common'; import { EntityDataStreamType } from '@kbn/observability-shared-plugin/common'; -import type { ObservabilityElasticsearchClient } from '@kbn/observability-utils-server/es/client/create_observability_es_client'; +import type { ObservabilityElasticsearchClient } from '@kbn/traced-es-client'; import { castArray } from 'lodash'; import type { Logger } from '@kbn/logging'; import { type InfraMetricsClient } from '../../lib/helpers/get_infra_metrics_client'; diff --git a/x-pack/solutions/observability/plugins/infra/server/routes/entities/index.ts b/x-pack/solutions/observability/plugins/infra/server/routes/entities/index.ts index e195a6da6d72f..e2d9f7cc4277f 100644 --- a/x-pack/solutions/observability/plugins/infra/server/routes/entities/index.ts +++ b/x-pack/solutions/observability/plugins/infra/server/routes/entities/index.ts @@ -8,7 +8,7 @@ import { schema } from '@kbn/config-schema'; import { METRICS_APP_ID } from '@kbn/deeplinks-observability/constants'; import { entityCentricExperience } from '@kbn/observability-plugin/common'; -import { createObservabilityEsClient } from '@kbn/observability-utils-server/es/client/create_observability_es_client'; +import { createObservabilityEsClient } from '@kbn/traced-es-client'; import { BUILT_IN_ENTITY_TYPES } from '@kbn/observability-shared-plugin/common'; import { getInfraMetricsClient } from '../../lib/helpers/get_infra_metrics_client'; import type { InfraBackendLibs } from '../../lib/infra_types'; diff --git a/x-pack/solutions/observability/plugins/investigate_app/server/routes/rca/route.ts b/x-pack/solutions/observability/plugins/investigate_app/server/routes/rca/route.ts index c4b71d7faa4b9..8215c1d13967b 100644 --- a/x-pack/solutions/observability/plugins/investigate_app/server/routes/rca/route.ts +++ b/x-pack/solutions/observability/plugins/investigate_app/server/routes/rca/route.ts @@ -14,7 +14,7 @@ import { import { z } from '@kbn/zod'; import datemath from '@elastic/datemath'; import { OBSERVABILITY_LOGS_DATA_ACCESS_LOG_SOURCES_ID } from '@kbn/management-settings-ids'; -import { createObservabilityEsClient } from '@kbn/observability-utils-server/es/client/create_observability_es_client'; +import { createObservabilityEsClient } from '@kbn/traced-es-client'; import { preconditionFailed } from '@hapi/boom'; import { createInvestigateAppServerRoute } from '../create_investigate_app_server_route'; import { investigationRepositoryFactory } from '../../services/investigation_repository'; diff --git a/x-pack/solutions/observability/plugins/observability_ai_assistant_app/server/clients/create_observability_ai_assistant_app_es_client.ts b/x-pack/solutions/observability/plugins/observability_ai_assistant_app/server/clients/create_observability_ai_assistant_app_es_client.ts index babb6c1273370..8193f96fa0147 100644 --- a/x-pack/solutions/observability/plugins/observability_ai_assistant_app/server/clients/create_observability_ai_assistant_app_es_client.ts +++ b/x-pack/solutions/observability/plugins/observability_ai_assistant_app/server/clients/create_observability_ai_assistant_app_es_client.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { createObservabilityEsClient } from '@kbn/observability-utils-server/es/client/create_observability_es_client'; +import { createObservabilityEsClient } from '@kbn/traced-es-client'; import { ElasticsearchClient, Logger } from '@kbn/core/server'; export async function createObservabilityAIAssistantAppEsClient({ diff --git a/x-pack/solutions/observability/plugins/streams/server/routes/esql/route.ts b/x-pack/solutions/observability/plugins/streams/server/routes/esql/route.ts index 33bcb3a74c6b6..d9560658f3c85 100644 --- a/x-pack/solutions/observability/plugins/streams/server/routes/esql/route.ts +++ b/x-pack/solutions/observability/plugins/streams/server/routes/esql/route.ts @@ -8,10 +8,7 @@ import { excludeFrozenQuery } from '@kbn/observability-utils-common/es/queries/exclude_frozen_query'; import { kqlQuery } from '@kbn/observability-utils-common/es/queries/kql_query'; import { rangeQuery } from '@kbn/observability-utils-common/es/queries/range_query'; -import { - UnparsedEsqlResponse, - createObservabilityEsClient, -} from '@kbn/observability-utils-server/es/client/create_observability_es_client'; +import { UnparsedEsqlResponse, createObservabilityEsClient } from '@kbn/traced-es-client'; import { z } from '@kbn/zod'; import { isNumber } from 'lodash'; import { createServerRoute } from '../create_server_route'; diff --git a/x-pack/solutions/observability/plugins/streams_app/public/components/esql_chart/controlled_esql_chart.tsx b/x-pack/solutions/observability/plugins/streams_app/public/components/esql_chart/controlled_esql_chart.tsx index 9008f8ee47098..60718bee7b1ff 100644 --- a/x-pack/solutions/observability/plugins/streams_app/public/components/esql_chart/controlled_esql_chart.tsx +++ b/x-pack/solutions/observability/plugins/streams_app/public/components/esql_chart/controlled_esql_chart.tsx @@ -23,7 +23,7 @@ import { i18n } from '@kbn/i18n'; import { getTimeZone } from '@kbn/observability-utils-browser/utils/ui_settings/get_timezone'; import { css } from '@emotion/css'; import { AbortableAsyncState } from '@kbn/observability-utils-browser/hooks/use_abortable_async'; -import type { UnparsedEsqlResponse } from '@kbn/observability-utils-server/es/client/create_observability_es_client'; +import type { UnparsedEsqlResponse } from '@kbn/traced-es-client'; import { esqlResultToTimeseries } from '../../util/esql_result_to_timeseries'; import { useKibana } from '../../hooks/use_kibana'; import { LoadingPanel } from '../loading_panel'; diff --git a/x-pack/solutions/observability/plugins/streams_app/public/util/esql_result_to_timeseries.ts b/x-pack/solutions/observability/plugins/streams_app/public/util/esql_result_to_timeseries.ts index c32bbf89135bd..1058a4f484965 100644 --- a/x-pack/solutions/observability/plugins/streams_app/public/util/esql_result_to_timeseries.ts +++ b/x-pack/solutions/observability/plugins/streams_app/public/util/esql_result_to_timeseries.ts @@ -5,7 +5,7 @@ * 2.0. */ import type { AbortableAsyncState } from '@kbn/observability-utils-browser/hooks/use_abortable_async'; -import type { UnparsedEsqlResponse } from '@kbn/observability-utils-server/es/client/create_observability_es_client'; +import type { UnparsedEsqlResponse } from '@kbn/traced-es-client'; import { orderBy } from 'lodash'; interface Timeseries { diff --git a/yarn.lock b/yarn.lock index 6413aef67c73b..458806cfbb5f3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7801,6 +7801,10 @@ version "0.0.0" uid "" +"@kbn/traced-es-client@link:src/platform/packages/shared/kbn-traced-es-client": + version "0.0.0" + uid "" + "@kbn/transform-plugin@link:x-pack/platform/plugins/private/transform": version "0.0.0" uid "" From 611c15d4f4ab5a3123ca177992b601aecefa3c96 Mon Sep 17 00:00:00 2001 From: Joe Reuter Date: Tue, 18 Feb 2025 14:59:25 +0100 Subject: [PATCH 06/15] wrap up --- src/platform/packages/shared/kbn-traced-es-client/README.md | 4 ++++ src/platform/packages/shared/kbn-traced-es-client/index.ts | 2 +- ...bservability_es_client.ts => create_traced_es_client.ts} | 6 +++--- .../plugins/infra/server/routes/entities/index.ts | 4 ++-- .../plugins/investigate_app/server/routes/rca/route.ts | 4 ++-- .../create_observability_ai_assistant_app_es_client.ts | 4 ++-- .../plugins/streams/server/routes/esql/route.ts | 4 ++-- 7 files changed, 16 insertions(+), 12 deletions(-) create mode 100644 src/platform/packages/shared/kbn-traced-es-client/README.md rename src/platform/packages/shared/kbn-traced-es-client/src/{create_observability_es_client.ts => create_traced_es_client.ts} (97%) diff --git a/src/platform/packages/shared/kbn-traced-es-client/README.md b/src/platform/packages/shared/kbn-traced-es-client/README.md new file mode 100644 index 0000000000000..eb97e7122a1b8 --- /dev/null +++ b/src/platform/packages/shared/kbn-traced-es-client/README.md @@ -0,0 +1,4 @@ +# Traced ES Client + +This package provides a wrapper around the regular platform ES client which adds tracing information for better analysis. +Each operation can be given a custom name that shows up as a trace when instrumenting using APM. \ No newline at end of file diff --git a/src/platform/packages/shared/kbn-traced-es-client/index.ts b/src/platform/packages/shared/kbn-traced-es-client/index.ts index 6365216d0ee9a..6b0fcebc8e3b9 100644 --- a/src/platform/packages/shared/kbn-traced-es-client/index.ts +++ b/src/platform/packages/shared/kbn-traced-es-client/index.ts @@ -7,4 +7,4 @@ * License v3.0 only", or the "Server Side Public License, v 1". */ -export * from './src/create_observability_es_client'; +export * from './src/create_traced_es_client'; diff --git a/src/platform/packages/shared/kbn-traced-es-client/src/create_observability_es_client.ts b/src/platform/packages/shared/kbn-traced-es-client/src/create_traced_es_client.ts similarity index 97% rename from src/platform/packages/shared/kbn-traced-es-client/src/create_observability_es_client.ts rename to src/platform/packages/shared/kbn-traced-es-client/src/create_traced_es_client.ts index ca793db8a1080..1c95770a72510 100644 --- a/src/platform/packages/shared/kbn-traced-es-client/src/create_observability_es_client.ts +++ b/src/platform/packages/shared/kbn-traced-es-client/src/create_traced_es_client.ts @@ -80,7 +80,7 @@ export type EsqlQueryResponse = UnparsedEsqlResponse | ParsedEsqlResponse; * An Elasticsearch Client with a fully typed `search` method and built-in * APM instrumentation. */ -export interface ObservabilityElasticsearchClient { +export interface TracedElasticsearchClient { search( operationName: string, parameters: TSearchRequest @@ -110,7 +110,7 @@ export interface ObservabilityElasticsearchClient { client: ElasticsearchClient; } -export function createObservabilityEsClient({ +export function createTracedEsClient({ client, logger, plugin, @@ -120,7 +120,7 @@ export function createObservabilityEsClient({ logger: Logger; plugin?: string; labels?: Record; -}): ObservabilityElasticsearchClient { +}): TracedElasticsearchClient { // wraps the ES calls in a named APM span for better analysis // (otherwise it would just eg be a _search span) const callWithLogger = ( diff --git a/x-pack/solutions/observability/plugins/infra/server/routes/entities/index.ts b/x-pack/solutions/observability/plugins/infra/server/routes/entities/index.ts index e2d9f7cc4277f..8c9b60589b69b 100644 --- a/x-pack/solutions/observability/plugins/infra/server/routes/entities/index.ts +++ b/x-pack/solutions/observability/plugins/infra/server/routes/entities/index.ts @@ -8,7 +8,7 @@ import { schema } from '@kbn/config-schema'; import { METRICS_APP_ID } from '@kbn/deeplinks-observability/constants'; import { entityCentricExperience } from '@kbn/observability-plugin/common'; -import { createObservabilityEsClient } from '@kbn/traced-es-client'; +import { createTracedEsClient } from '@kbn/traced-es-client'; import { BUILT_IN_ENTITY_TYPES } from '@kbn/observability-shared-plugin/common'; import { getInfraMetricsClient } from '../../lib/helpers/get_infra_metrics_client'; import type { InfraBackendLibs } from '../../lib/infra_types'; @@ -55,7 +55,7 @@ export const initEntitiesConfigurationRoutes = (libs: InfraBackendLibs) => { context: requestContext, }); - const obsEsClient = createObservabilityEsClient({ + const obsEsClient = createTracedEsClient({ client: coreContext.elasticsearch.client.asCurrentUser, logger, plugin: `@kbn/${METRICS_APP_ID}-plugin`, diff --git a/x-pack/solutions/observability/plugins/investigate_app/server/routes/rca/route.ts b/x-pack/solutions/observability/plugins/investigate_app/server/routes/rca/route.ts index 8215c1d13967b..7aa27e88fca9c 100644 --- a/x-pack/solutions/observability/plugins/investigate_app/server/routes/rca/route.ts +++ b/x-pack/solutions/observability/plugins/investigate_app/server/routes/rca/route.ts @@ -14,7 +14,7 @@ import { import { z } from '@kbn/zod'; import datemath from '@elastic/datemath'; import { OBSERVABILITY_LOGS_DATA_ACCESS_LOG_SOURCES_ID } from '@kbn/management-settings-ids'; -import { createObservabilityEsClient } from '@kbn/traced-es-client'; +import { createTracedEsClient } from '@kbn/traced-es-client'; import { preconditionFailed } from '@hapi/boom'; import { createInvestigateAppServerRoute } from '../create_investigate_app_server_route'; import { investigationRepositoryFactory } from '../../services/investigation_repository'; @@ -69,7 +69,7 @@ export const rootCauseAnalysisRoute = createInvestigateAppServerRoute({ const repository = investigationRepositoryFactory({ soClient, logger }); - const esClient = createObservabilityEsClient({ + const esClient = createTracedEsClient({ client: coreEsClient, logger, plugin: 'investigateApp', diff --git a/x-pack/solutions/observability/plugins/observability_ai_assistant_app/server/clients/create_observability_ai_assistant_app_es_client.ts b/x-pack/solutions/observability/plugins/observability_ai_assistant_app/server/clients/create_observability_ai_assistant_app_es_client.ts index 8193f96fa0147..b7f8414d4179f 100644 --- a/x-pack/solutions/observability/plugins/observability_ai_assistant_app/server/clients/create_observability_ai_assistant_app_es_client.ts +++ b/x-pack/solutions/observability/plugins/observability_ai_assistant_app/server/clients/create_observability_ai_assistant_app_es_client.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { createObservabilityEsClient } from '@kbn/traced-es-client'; +import { createTracedEsClient } from '@kbn/traced-es-client'; import { ElasticsearchClient, Logger } from '@kbn/core/server'; export async function createObservabilityAIAssistantAppEsClient({ @@ -15,7 +15,7 @@ export async function createObservabilityAIAssistantAppEsClient({ client: ElasticsearchClient; logger: Logger; }) { - const esClient = createObservabilityEsClient({ + const esClient = createTracedEsClient({ client, logger, plugin: 'observabilityAIAssistantApp', diff --git a/x-pack/solutions/observability/plugins/streams/server/routes/esql/route.ts b/x-pack/solutions/observability/plugins/streams/server/routes/esql/route.ts index d9560658f3c85..73a8ab7e60b05 100644 --- a/x-pack/solutions/observability/plugins/streams/server/routes/esql/route.ts +++ b/x-pack/solutions/observability/plugins/streams/server/routes/esql/route.ts @@ -8,7 +8,7 @@ import { excludeFrozenQuery } from '@kbn/observability-utils-common/es/queries/exclude_frozen_query'; import { kqlQuery } from '@kbn/observability-utils-common/es/queries/kql_query'; import { rangeQuery } from '@kbn/observability-utils-common/es/queries/range_query'; -import { UnparsedEsqlResponse, createObservabilityEsClient } from '@kbn/traced-es-client'; +import { UnparsedEsqlResponse, createTracedEsClient } from '@kbn/traced-es-client'; import { z } from '@kbn/zod'; import { isNumber } from 'lodash'; import { createServerRoute } from '../create_server_route'; @@ -37,7 +37,7 @@ export const executeEsqlRoute = createServerRoute({ }), handler: async ({ params, request, logger, getScopedClients }): Promise => { const { scopedClusterClient } = await getScopedClients({ request }); - const observabilityEsClient = createObservabilityEsClient({ + const observabilityEsClient = createTracedEsClient({ client: scopedClusterClient.asCurrentUser, logger, plugin: 'streams', From ce3a5fd646534d65e8515c0c8654bc88b359cf92 Mon Sep 17 00:00:00 2001 From: Joe Reuter Date: Tue, 18 Feb 2025 15:01:16 +0100 Subject: [PATCH 07/15] typo --- src/platform/packages/shared/kbn-storage-adapter/jest.config.js | 2 +- .../shared/kbn-storage-adapter/jest.integration.config.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/platform/packages/shared/kbn-storage-adapter/jest.config.js b/src/platform/packages/shared/kbn-storage-adapter/jest.config.js index f525ee104da1e..b57eea71d6736 100644 --- a/src/platform/packages/shared/kbn-storage-adapter/jest.config.js +++ b/src/platform/packages/shared/kbn-storage-adapter/jest.config.js @@ -10,5 +10,5 @@ module.exports = { preset: '@kbn/test', rootDir: '../../../../..', - roots: ['/src/platform/packages/shated/kbn-storage-adapter'], + roots: ['/src/platform/packages/shared/kbn-storage-adapter'], }; diff --git a/src/platform/packages/shared/kbn-storage-adapter/jest.integration.config.js b/src/platform/packages/shared/kbn-storage-adapter/jest.integration.config.js index 7102763976ecb..fd94989254e1f 100644 --- a/src/platform/packages/shared/kbn-storage-adapter/jest.integration.config.js +++ b/src/platform/packages/shared/kbn-storage-adapter/jest.integration.config.js @@ -10,5 +10,5 @@ module.exports = { preset: '@kbn/test/jest_integration', rootDir: '../../../../..', - roots: ['/src/platform/packages/shated/kbn-storage-adapter'], + roots: ['/src/platform/packages/shared/kbn-storage-adapter'], }; From 69c8a11a876bdea5ba5776806e8c898486399fc9 Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Tue, 18 Feb 2025 14:12:58 +0000 Subject: [PATCH 08/15] [CI] Auto-commit changed files from 'node scripts/generate codeowners' --- .github/CODEOWNERS | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index f2f7c02e692b9..8549a2e263ffe 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -533,6 +533,7 @@ src/platform/packages/shared/kbn-sse-utils-server @elastic/obs-knowledge-team src/platform/packages/shared/kbn-std @elastic/kibana-core src/platform/packages/shared/kbn-storage-adapter @elastic/observability-ui src/platform/packages/shared/kbn-timerange @elastic/obs-ux-logs-team +src/platform/packages/shared/kbn-traced-es-client @elastic/observability-ui src/platform/packages/shared/kbn-triggers-actions-ui-types @elastic/response-ops src/platform/packages/shared/kbn-try-in-console @elastic/search-kibana src/platform/packages/shared/kbn-typed-react-router-config @elastic/obs-knowledge-team @elastic/obs-ux-infra_services-team From f438c98f8dd79482c3db0763da31954cba4ba9c9 Mon Sep 17 00:00:00 2001 From: Joe Reuter Date: Tue, 18 Feb 2025 15:43:53 +0100 Subject: [PATCH 09/15] fix references --- .../packages/utils-server/entities/analyze_documents.ts | 4 ++-- .../utils-server/entities/get_data_streams_for_entity.ts | 4 ++-- .../utils-server/entities/get_entities_by_fuzzy_search.ts | 4 ++-- .../packages/utils-server/entities/get_log_patterns.ts | 6 +++--- .../utils-server/entities/signals/get_slos_for_entity.ts | 4 ++-- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/x-pack/solutions/observability/packages/utils-server/entities/analyze_documents.ts b/x-pack/solutions/observability/packages/utils-server/entities/analyze_documents.ts index bf9d85cd54747..41caa7920f9a9 100644 --- a/x-pack/solutions/observability/packages/utils-server/entities/analyze_documents.ts +++ b/x-pack/solutions/observability/packages/utils-server/entities/analyze_documents.ts @@ -8,7 +8,7 @@ import { mapValues } from 'lodash'; import { mergeSampleDocumentsWithFieldCaps } from '@kbn/observability-utils-common/llm/log_analysis/merge_sample_documents_with_field_caps'; import { DocumentAnalysis } from '@kbn/observability-utils-common/llm/log_analysis/document_analysis'; -import type { ObservabilityElasticsearchClient } from '../es/client/create_observability_es_client'; +import type { TracedElasticsearchClient } from '@kbn/traced-es-client'; import { kqlQuery } from '../es/queries/kql_query'; import { rangeQuery } from '../es/queries/range_query'; @@ -19,7 +19,7 @@ export async function analyzeDocuments({ end, index, }: { - esClient: ObservabilityElasticsearchClient; + esClient: TracedElasticsearchClient; kuery: string; start: number; end: number; diff --git a/x-pack/solutions/observability/packages/utils-server/entities/get_data_streams_for_entity.ts b/x-pack/solutions/observability/packages/utils-server/entities/get_data_streams_for_entity.ts index 9265a461db22e..b4f803bbb1944 100644 --- a/x-pack/solutions/observability/packages/utils-server/entities/get_data_streams_for_entity.ts +++ b/x-pack/solutions/observability/packages/utils-server/entities/get_data_streams_for_entity.ts @@ -6,7 +6,7 @@ */ import { compact, uniq } from 'lodash'; -import { ObservabilityElasticsearchClient } from '../es/client/create_observability_es_client'; +import type { TracedElasticsearchClient } from '@kbn/traced-es-client'; import { excludeFrozenQuery } from '../es/queries/exclude_frozen_query'; import { kqlQuery } from '../es/queries/kql_query'; @@ -15,7 +15,7 @@ export async function getDataStreamsForEntity({ kuery, index, }: { - esClient: ObservabilityElasticsearchClient; + esClient: TracedElasticsearchClient; kuery: string; index: string | string[]; }) { diff --git a/x-pack/solutions/observability/packages/utils-server/entities/get_entities_by_fuzzy_search.ts b/x-pack/solutions/observability/packages/utils-server/entities/get_entities_by_fuzzy_search.ts index aedf89b2ab97d..f54179a67a1e2 100644 --- a/x-pack/solutions/observability/packages/utils-server/entities/get_entities_by_fuzzy_search.ts +++ b/x-pack/solutions/observability/packages/utils-server/entities/get_entities_by_fuzzy_search.ts @@ -7,7 +7,7 @@ import { castArray, orderBy } from 'lodash'; import Fuse from 'fuse.js'; -import { ObservabilityElasticsearchClient } from '../es/client/create_observability_es_client'; +import { TracedElasticsearchClient } from '@kbn/traced-es-client'; export async function getEntitiesByFuzzySearch({ esClient, @@ -16,7 +16,7 @@ export async function getEntitiesByFuzzySearch({ end, index, }: { - esClient: ObservabilityElasticsearchClient; + esClient: TracedElasticsearchClient; entity: Record; start: number; end: number; diff --git a/x-pack/solutions/observability/packages/utils-server/entities/get_log_patterns.ts b/x-pack/solutions/observability/packages/utils-server/entities/get_log_patterns.ts index b4071d665f383..d179d8d2bfab7 100644 --- a/x-pack/solutions/observability/packages/utils-server/entities/get_log_patterns.ts +++ b/x-pack/solutions/observability/packages/utils-server/entities/get_log_patterns.ts @@ -19,7 +19,7 @@ import { pValueToLabel } from '@kbn/observability-utils-common/ml/p_value_to_lab import { calculateAuto } from '@kbn/calculate-auto'; import { omit, orderBy, uniqBy } from 'lodash'; import moment from 'moment'; -import { ObservabilityElasticsearchClient } from '../es/client/create_observability_es_client'; +import { TracedElasticsearchClient } from '@kbn/traced-es-client'; import { kqlQuery } from '../es/queries/kql_query'; import { rangeQuery } from '../es/queries/range_query'; @@ -54,7 +54,7 @@ export type FieldPatternResultWithChanges = FieldPatternResult; interface CategorizeTextOptions { query: QueryDslQueryContainer; metadata: string[]; - esClient: ObservabilityElasticsearchClient; + esClient: TracedElasticsearchClient; samplingProbability: number; fields: string[]; index: string | string[]; @@ -247,7 +247,7 @@ export async function runCategorizeTextAggregation({ } interface LogPatternOptions { - esClient: ObservabilityElasticsearchClient; + esClient: TracedElasticsearchClient; start: number; end: number; index: string | string[]; diff --git a/x-pack/solutions/observability/packages/utils-server/entities/signals/get_slos_for_entity.ts b/x-pack/solutions/observability/packages/utils-server/entities/signals/get_slos_for_entity.ts index fc3a9d7b26d5c..99c58715ddaa6 100644 --- a/x-pack/solutions/observability/packages/utils-server/entities/signals/get_slos_for_entity.ts +++ b/x-pack/solutions/observability/packages/utils-server/entities/signals/get_slos_for_entity.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { ObservabilityElasticsearchClient } from '../../es/client/create_observability_es_client'; +import { TracedElasticsearchClient } from '@kbn/traced-es-client'; import { kqlQuery } from '../../es/queries/kql_query'; export async function getSlosForEntity({ @@ -20,7 +20,7 @@ export async function getSlosForEntity({ start: number; end: number; entity: Record; - esClient: ObservabilityElasticsearchClient; + esClient: TracedElasticsearchClient; sloSummaryIndices: string | string[]; size: number; spaceId: string; From 9e33b87899472a869a18eb5129fef1168cf9220e Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Tue, 18 Feb 2025 14:55:16 +0000 Subject: [PATCH 10/15] [CI] Auto-commit changed files from 'node scripts/notice' --- .../packages/shared/kbn-traced-es-client/tsconfig.json | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/platform/packages/shared/kbn-traced-es-client/tsconfig.json b/src/platform/packages/shared/kbn-traced-es-client/tsconfig.json index 4546c8c069a95..25b465c125b00 100644 --- a/src/platform/packages/shared/kbn-traced-es-client/tsconfig.json +++ b/src/platform/packages/shared/kbn-traced-es-client/tsconfig.json @@ -19,16 +19,7 @@ "@kbn/core", "@kbn/es-types", "@kbn/apm-utils", - "@kbn/es-query", - "@kbn/observability-utils-common", - "@kbn/alerting-plugin", - "@kbn/rule-registry-plugin", - "@kbn/rule-data-utils", - "@kbn/aiops-log-pattern-analysis", - "@kbn/calculate-auto", "@kbn/utility-types", "@kbn/task-manager-plugin", - "@kbn/es-errors", - "@kbn/core-test-helpers-kbn-server", ] } From 91804a9f2feb482092930cb2403fe1aae683d93c Mon Sep 17 00:00:00 2001 From: Joe Reuter Date: Tue, 18 Feb 2025 16:14:01 +0100 Subject: [PATCH 11/15] fix immports --- .../solutions/observability/packages/utils-server/tsconfig.json | 1 + 1 file changed, 1 insertion(+) diff --git a/x-pack/solutions/observability/packages/utils-server/tsconfig.json b/x-pack/solutions/observability/packages/utils-server/tsconfig.json index 33d7e75322f00..b015f8a97b1fb 100644 --- a/x-pack/solutions/observability/packages/utils-server/tsconfig.json +++ b/x-pack/solutions/observability/packages/utils-server/tsconfig.json @@ -21,6 +21,7 @@ "@kbn/apm-utils", "@kbn/es-query", "@kbn/observability-utils-common", + "@kbn/traced-es-client", "@kbn/alerting-plugin", "@kbn/rule-registry-plugin", "@kbn/rule-data-utils", From c094d661d99e144560ecb77fba403caa32c3136c Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Tue, 18 Feb 2025 15:27:17 +0000 Subject: [PATCH 12/15] [CI] Auto-commit changed files from 'node scripts/styled_components_mapping' --- .../observability-ai/observability-ai-server/tsconfig.json | 1 + .../observability/packages/utils-server/tsconfig.json | 4 ---- x-pack/solutions/observability/plugins/infra/tsconfig.json | 4 ++-- .../observability/plugins/investigate_app/tsconfig.json | 2 +- .../plugins/observability_ai_assistant_app/tsconfig.json | 4 ++-- x-pack/solutions/observability/plugins/streams/tsconfig.json | 3 ++- .../solutions/observability/plugins/streams_app/tsconfig.json | 4 ++-- 7 files changed, 10 insertions(+), 12 deletions(-) diff --git a/x-pack/solutions/observability/packages/observability-ai/observability-ai-server/tsconfig.json b/x-pack/solutions/observability/packages/observability-ai/observability-ai-server/tsconfig.json index 59f73df4273c8..7a43777d519ed 100644 --- a/x-pack/solutions/observability/packages/observability-ai/observability-ai-server/tsconfig.json +++ b/x-pack/solutions/observability/packages/observability-ai/observability-ai-server/tsconfig.json @@ -25,5 +25,6 @@ "@kbn/inference-common", "@kbn/observability-ai-common", "@kbn/observability-utils-server", + "@kbn/traced-es-client", ] } diff --git a/x-pack/solutions/observability/packages/utils-server/tsconfig.json b/x-pack/solutions/observability/packages/utils-server/tsconfig.json index b015f8a97b1fb..f7cf4e0940bc0 100644 --- a/x-pack/solutions/observability/packages/utils-server/tsconfig.json +++ b/x-pack/solutions/observability/packages/utils-server/tsconfig.json @@ -16,9 +16,7 @@ "target/**/*" ], "kbn_references": [ - "@kbn/core", "@kbn/es-types", - "@kbn/apm-utils", "@kbn/es-query", "@kbn/observability-utils-common", "@kbn/traced-es-client", @@ -27,7 +25,5 @@ "@kbn/rule-data-utils", "@kbn/aiops-log-pattern-analysis", "@kbn/calculate-auto", - "@kbn/utility-types", - "@kbn/task-manager-plugin", ] } diff --git a/x-pack/solutions/observability/plugins/infra/tsconfig.json b/x-pack/solutions/observability/plugins/infra/tsconfig.json index b4139513973b4..e2c5f9ed48017 100644 --- a/x-pack/solutions/observability/plugins/infra/tsconfig.json +++ b/x-pack/solutions/observability/plugins/infra/tsconfig.json @@ -110,14 +110,14 @@ "@kbn/shared-ux-page-no-data-types", "@kbn/entityManager-plugin", "@kbn/zod", - "@kbn/observability-utils-server", "@kbn/core-plugins-server", "@kbn/config", "@kbn/observability-utils-common", "@kbn/charts-theme", "@kbn/response-ops-rule-params", "@kbn/core-test-helpers-model-versions", - "@kbn/deeplinks-management" + "@kbn/deeplinks-management", + "@kbn/traced-es-client" ], "exclude": ["target/**/*"] } diff --git a/x-pack/solutions/observability/plugins/investigate_app/tsconfig.json b/x-pack/solutions/observability/plugins/investigate_app/tsconfig.json index e467bd40918fd..b04f4b96186ba 100644 --- a/x-pack/solutions/observability/plugins/investigate_app/tsconfig.json +++ b/x-pack/solutions/observability/plugins/investigate_app/tsconfig.json @@ -60,7 +60,6 @@ "@kbn/observability-plugin", "@kbn/observability-shared-plugin", "@kbn/observability-utils-browser", - "@kbn/observability-utils-server", "@kbn/presentation-containers", "@kbn/react-kibana-context-theme", "@kbn/rule-data-utils", @@ -86,5 +85,6 @@ "@kbn/dev-cli-runner", "@kbn/datemath", "@kbn/sse-utils-client", + "@kbn/traced-es-client", ], } diff --git a/x-pack/solutions/observability/plugins/observability_ai_assistant_app/tsconfig.json b/x-pack/solutions/observability/plugins/observability_ai_assistant_app/tsconfig.json index 145005f900fa1..fc44d273a9efe 100644 --- a/x-pack/solutions/observability/plugins/observability_ai_assistant_app/tsconfig.json +++ b/x-pack/solutions/observability/plugins/observability_ai_assistant_app/tsconfig.json @@ -70,7 +70,6 @@ "@kbn/cloud-plugin", "@kbn/logs-data-access-plugin", "@kbn/ai-assistant-common", - "@kbn/observability-utils-server", "@kbn/observability-utils-common", "@kbn/slo-plugin", "@kbn/spaces-plugin", @@ -86,7 +85,8 @@ "@kbn/rule-data-utils", "@kbn/i18n-react", "@kbn/utility-types", - "@kbn/alerts-ui-shared" + "@kbn/alerts-ui-shared", + "@kbn/traced-es-client" ], "exclude": ["target/**/*"] } diff --git a/x-pack/solutions/observability/plugins/streams/tsconfig.json b/x-pack/solutions/observability/plugins/streams/tsconfig.json index 7118e33758af7..9cfa80a21120c 100644 --- a/x-pack/solutions/observability/plugins/streams/tsconfig.json +++ b/x-pack/solutions/observability/plugins/streams/tsconfig.json @@ -37,6 +37,7 @@ "@kbn/streams-schema", "@kbn/es-errors", "@kbn/server-route-repository-utils", - "@kbn/storage-adapter" + "@kbn/storage-adapter", + "@kbn/traced-es-client" ] } diff --git a/x-pack/solutions/observability/plugins/streams_app/tsconfig.json b/x-pack/solutions/observability/plugins/streams_app/tsconfig.json index 3ed3937f15180..823aef5358381 100644 --- a/x-pack/solutions/observability/plugins/streams_app/tsconfig.json +++ b/x-pack/solutions/observability/plugins/streams_app/tsconfig.json @@ -28,7 +28,6 @@ "@kbn/react-kibana-context-render", "@kbn/code-editor", "@kbn/observability-utils-browser", - "@kbn/observability-utils-server", "@kbn/ui-theme", "@kbn/calculate-auto", "@kbn/kibana-react-plugin", @@ -58,6 +57,7 @@ "@kbn/fields-metadata-plugin", "@kbn/datemath", "@kbn/dataset-quality-plugin", - "@kbn/search-types" + "@kbn/search-types", + "@kbn/traced-es-client" ] } From 86ef6f6e117bd7bf8c4b2d3c15cee773edc8179d Mon Sep 17 00:00:00 2001 From: Joe Reuter Date: Tue, 18 Feb 2025 16:52:11 +0100 Subject: [PATCH 13/15] fix more places --- .../root_cause_analysis/run_root_cause_analysis.ts | 4 ++-- .../analyze_fetched_related_entities.ts | 4 ++-- .../tasks/find_related_entities/index.ts | 4 ++-- .../observability-ai-server/root_cause_analysis/types.ts | 4 ++-- .../server/routes/entities/get_data_stream_types.test.ts | 6 +++--- .../infra/server/routes/entities/get_data_stream_types.ts | 4 ++-- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/x-pack/solutions/observability/packages/observability-ai/observability-ai-server/root_cause_analysis/run_root_cause_analysis.ts b/x-pack/solutions/observability/packages/observability-ai/observability-ai-server/root_cause_analysis/run_root_cause_analysis.ts index 0c44b76ca0b94..47ec49a6a4abd 100644 --- a/x-pack/solutions/observability/packages/observability-ai/observability-ai-server/root_cause_analysis/run_root_cause_analysis.ts +++ b/x-pack/solutions/observability/packages/observability-ai/observability-ai-server/root_cause_analysis/run_root_cause_analysis.ts @@ -15,7 +15,7 @@ import { findLast, pick } from 'lodash'; import moment from 'moment'; import { catchError, filter, from, map, mergeMap, Observable, of, switchMap } from 'rxjs'; import { ObservabilityAIAssistantClient } from '@kbn/observability-ai-assistant-plugin/server'; -import { ObservabilityElasticsearchClient } from '@kbn/traced-es-client'; +import { TracedElasticsearchClient } from '@kbn/traced-es-client'; import { RCA_END_PROCESS_TOOL_NAME, RCA_INVESTIGATE_ENTITY_TOOL_NAME, @@ -94,7 +94,7 @@ export function runRootCauseAnalysis({ end: number; alertsClient: AlertsClient; rulesClient: RulesClient; - esClient: ObservabilityElasticsearchClient; + esClient: TracedElasticsearchClient; observabilityAIAssistantClient: ObservabilityAIAssistantClient; indices: { logs: string[]; diff --git a/x-pack/solutions/observability/packages/observability-ai/observability-ai-server/root_cause_analysis/tasks/find_related_entities/analyze_fetched_related_entities.ts b/x-pack/solutions/observability/packages/observability-ai/observability-ai-server/root_cause_analysis/tasks/find_related_entities/analyze_fetched_related_entities.ts index d625bb3fb12cd..f25d4eeff0fd0 100644 --- a/x-pack/solutions/observability/packages/observability-ai/observability-ai-server/root_cause_analysis/tasks/find_related_entities/analyze_fetched_related_entities.ts +++ b/x-pack/solutions/observability/packages/observability-ai/observability-ai-server/root_cause_analysis/tasks/find_related_entities/analyze_fetched_related_entities.ts @@ -15,7 +15,7 @@ import { import { sortAndTruncateAnalyzedFields } from '@kbn/observability-utils-common/llm/log_analysis/sort_and_truncate_analyzed_fields'; import { analyzeDocuments } from '@kbn/observability-utils-server/entities/analyze_documents'; import { FieldPatternResultWithChanges } from '@kbn/observability-utils-server/entities/get_log_patterns'; -import { ObservabilityElasticsearchClient } from '@kbn/traced-es-client'; +import { TracedElasticsearchClient } from '@kbn/traced-es-client'; import { kqlQuery } from '@kbn/observability-utils-server/es/queries/kql_query'; import { rangeQuery } from '@kbn/observability-utils-server/es/queries/range_query'; import { chunk, isEmpty, isEqual } from 'lodash'; @@ -202,7 +202,7 @@ export async function analyzeFetchedRelatedEntities({ }: { connectorId: string; inferenceClient: InferenceClient; - esClient: ObservabilityElasticsearchClient; + esClient: TracedElasticsearchClient; start: number; end: number; searches: RelatedEntityKeywordSearch[]; diff --git a/x-pack/solutions/observability/packages/observability-ai/observability-ai-server/root_cause_analysis/tasks/find_related_entities/index.ts b/x-pack/solutions/observability/packages/observability-ai/observability-ai-server/root_cause_analysis/tasks/find_related_entities/index.ts index 54117d9af4614..1a6edf06acd00 100644 --- a/x-pack/solutions/observability/packages/observability-ai/observability-ai-server/root_cause_analysis/tasks/find_related_entities/index.ts +++ b/x-pack/solutions/observability/packages/observability-ai/observability-ai-server/root_cause_analysis/tasks/find_related_entities/index.ts @@ -11,7 +11,7 @@ import { DocumentAnalysis, TruncatedDocumentAnalysis, } from '@kbn/observability-utils-common/llm/log_analysis/document_analysis'; -import { ObservabilityElasticsearchClient } from '@kbn/traced-es-client'; +import { TracedElasticsearchClient } from '@kbn/traced-es-client'; import { FieldPatternResultWithChanges } from '@kbn/observability-utils-server/entities/get_log_patterns'; import { analyzeFetchedRelatedEntities, @@ -45,7 +45,7 @@ export async function findRelatedEntities({ start: number; end: number; index: string | string[]; - esClient: ObservabilityElasticsearchClient; + esClient: TracedElasticsearchClient; entity: Record; analysis: { truncated: TruncatedDocumentAnalysis; diff --git a/x-pack/solutions/observability/packages/observability-ai/observability-ai-server/root_cause_analysis/types.ts b/x-pack/solutions/observability/packages/observability-ai/observability-ai-server/root_cause_analysis/types.ts index 814ab949d5af6..c61e2e94a2cc1 100644 --- a/x-pack/solutions/observability/packages/observability-ai/observability-ai-server/root_cause_analysis/types.ts +++ b/x-pack/solutions/observability/packages/observability-ai/observability-ai-server/root_cause_analysis/types.ts @@ -17,7 +17,7 @@ import { Logger } from '@kbn/logging'; import { AlertsClient } from '@kbn/rule-registry-plugin/server'; import { RulesClient } from '@kbn/alerting-plugin/server'; import { ObservabilityAIAssistantClient } from '@kbn/observability-ai-assistant-plugin/server'; -import { ObservabilityElasticsearchClient } from '@kbn/traced-es-client'; +import { TracedElasticsearchClient } from '@kbn/traced-es-client'; import { RCA_END_PROCESS_TOOL_NAME, RCA_INVESTIGATE_ENTITY_TOOL_NAME, @@ -92,7 +92,7 @@ export interface RootCauseAnalysisContext { inferenceClient: InferenceClient; tokenLimit: number; connectorId: string; - esClient: ObservabilityElasticsearchClient; + esClient: TracedElasticsearchClient; alertsClient: AlertsClient; rulesClient: RulesClient; logger: Logger; diff --git a/x-pack/solutions/observability/plugins/infra/server/routes/entities/get_data_stream_types.test.ts b/x-pack/solutions/observability/plugins/infra/server/routes/entities/get_data_stream_types.test.ts index 2570dbb3d8d7b..5331e7b46add1 100644 --- a/x-pack/solutions/observability/plugins/infra/server/routes/entities/get_data_stream_types.test.ts +++ b/x-pack/solutions/observability/plugins/infra/server/routes/entities/get_data_stream_types.test.ts @@ -4,7 +4,7 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ -import type { ObservabilityElasticsearchClient } from '@kbn/traced-es-client'; +import type { TracedElasticsearchClient } from '@kbn/traced-es-client'; import { type EntityClient } from '@kbn/entityManager-plugin/server/lib/entity_client'; import { type InfraMetricsClient } from '../../lib/helpers/get_infra_metrics_client'; import { getDataStreamTypes } from './get_data_stream_types'; @@ -22,13 +22,13 @@ jest.mock('./get_latest_entity', () => ({ describe('getDataStreamTypes', () => { let infraMetricsClient: jest.Mocked; - let obsEsClient: jest.Mocked; + let obsEsClient: jest.Mocked; let entityManagerClient: jest.Mocked; const logger = loggingSystemMock.createLogger(); beforeEach(() => { infraMetricsClient = {} as jest.Mocked; - obsEsClient = {} as jest.Mocked; + obsEsClient = {} as jest.Mocked; entityManagerClient = {} as jest.Mocked; jest.clearAllMocks(); }); diff --git a/x-pack/solutions/observability/plugins/infra/server/routes/entities/get_data_stream_types.ts b/x-pack/solutions/observability/plugins/infra/server/routes/entities/get_data_stream_types.ts index 274ac9049021e..a4666a91fb50d 100644 --- a/x-pack/solutions/observability/plugins/infra/server/routes/entities/get_data_stream_types.ts +++ b/x-pack/solutions/observability/plugins/infra/server/routes/entities/get_data_stream_types.ts @@ -9,7 +9,7 @@ import { type EntityClient } from '@kbn/entityManager-plugin/server/lib/entity_c import type { InventoryItemType } from '@kbn/metrics-data-access-plugin/common'; import { findInventoryFields } from '@kbn/metrics-data-access-plugin/common'; import { EntityDataStreamType } from '@kbn/observability-shared-plugin/common'; -import type { ObservabilityElasticsearchClient } from '@kbn/traced-es-client'; +import type { TracedElasticsearchClient } from '@kbn/traced-es-client'; import { castArray } from 'lodash'; import type { Logger } from '@kbn/logging'; import { type InfraMetricsClient } from '../../lib/helpers/get_infra_metrics_client'; @@ -22,7 +22,7 @@ interface Params { entityFilterType: string; entityCentricExperienceEnabled: boolean; infraMetricsClient: InfraMetricsClient; - obsEsClient: ObservabilityElasticsearchClient; + obsEsClient: TracedElasticsearchClient; entityManagerClient: EntityClient; logger: Logger; from: string; From 6d6f5c5ef418d8cf75d9e3a2fab356841f37dbcd Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Tue, 18 Feb 2025 16:05:00 +0000 Subject: [PATCH 14/15] [CI] Auto-commit changed files from 'node scripts/styled_components_mapping' --- x-pack/solutions/observability/plugins/streams_app/tsconfig.json | 1 - 1 file changed, 1 deletion(-) diff --git a/x-pack/solutions/observability/plugins/streams_app/tsconfig.json b/x-pack/solutions/observability/plugins/streams_app/tsconfig.json index 823aef5358381..835934e60c81b 100644 --- a/x-pack/solutions/observability/plugins/streams_app/tsconfig.json +++ b/x-pack/solutions/observability/plugins/streams_app/tsconfig.json @@ -39,7 +39,6 @@ "@kbn/calculate-auto", "@kbn/streams-plugin", "@kbn/share-plugin", - "@kbn/observability-utils-server", "@kbn/code-editor", "@kbn/ui-theme", "@kbn/navigation-plugin", From fc5715e6dcc55e5bb0f23bd060129a9640386a17 Mon Sep 17 00:00:00 2001 From: Joe Reuter Date: Tue, 18 Feb 2025 18:08:40 +0100 Subject: [PATCH 15/15] fix import --- .../root_cause_analysis/tasks/investigate_entity/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x-pack/solutions/observability/packages/observability-ai/observability-ai-server/root_cause_analysis/tasks/investigate_entity/index.ts b/x-pack/solutions/observability/packages/observability-ai/observability-ai-server/root_cause_analysis/tasks/investigate_entity/index.ts index 8a9687e0ae852..9646a677733f3 100644 --- a/x-pack/solutions/observability/packages/observability-ai/observability-ai-server/root_cause_analysis/tasks/investigate_entity/index.ts +++ b/x-pack/solutions/observability/packages/observability-ai/observability-ai-server/root_cause_analysis/tasks/investigate_entity/index.ts @@ -11,7 +11,7 @@ import { analyzeDocuments } from '@kbn/observability-utils-server/entities/analy import { getDataStreamsForEntity } from '@kbn/observability-utils-server/entities/get_data_streams_for_entity'; import { getAlertsForEntity } from '@kbn/observability-utils-server/entities/signals/get_alerts_for_entity'; import { getSlosForEntity } from '@kbn/observability-utils-server/entities/signals/get_slos_for_entity'; -import { ObservabilityElasticsearchClient } from '@kbn/traced-es-client'; +import { TracedElasticsearchClient } from '@kbn/traced-es-client'; import { RootCauseAnalysisContext } from '../../types'; import { stringifySummaries } from '../../util/stringify_summaries'; import { analyzeLogPatterns } from '../analyze_log_patterns'; @@ -251,7 +251,7 @@ async function analyzeDataStreamsForEntity({ end: number; kuery: string; dataStreams: string[]; - esClient: ObservabilityElasticsearchClient; + esClient: TracedElasticsearchClient; }) { const analysis = await analyzeDocuments({ esClient,