diff --git a/docs/settings/fleet-settings.asciidoc b/docs/settings/fleet-settings.asciidoc index 084c8c25ad0c7..dfd92f1e9cf99 100644 --- a/docs/settings/fleet-settings.asciidoc +++ b/docs/settings/fleet-settings.asciidoc @@ -318,3 +318,6 @@ The features in this section are experimental and may be changed or removed comp Elastic will make a best effort to fix any issues, but experimental features are not supported to the same level as generally available (GA) features. ==== +`xpack.fleet.enableManagedLogsAndMetricsDataviews`:: +Set to `true` (default), to enable the automatic creation of global `logs-*` and `metrics-*` data views. + diff --git a/x-pack/platform/plugins/shared/fleet/common/types/index.ts b/x-pack/platform/plugins/shared/fleet/common/types/index.ts index f77ea38dc7b5f..69f150a7ca78a 100644 --- a/x-pack/platform/plugins/shared/fleet/common/types/index.ts +++ b/x-pack/platform/plugins/shared/fleet/common/types/index.ts @@ -50,6 +50,7 @@ export interface FleetConfigType { outputs?: PreconfiguredOutput[]; agentIdVerificationEnabled?: boolean; enableExperimental?: string[]; + enableManagedLogsAndMetricsDataviews?: boolean; packageVerification?: { gpgKeyPath?: string; }; diff --git a/x-pack/platform/plugins/shared/fleet/server/config.ts b/x-pack/platform/plugins/shared/fleet/server/config.ts index 8035f389db488..3a78c20c799fe 100644 --- a/x-pack/platform/plugins/shared/fleet/server/config.ts +++ b/x-pack/platform/plugins/shared/fleet/server/config.ts @@ -131,6 +131,7 @@ export const config: PluginConfigDescriptor = { { isAirGapped: schema.maybe(schema.boolean({ defaultValue: false })), enableDeleteUnenrolledAgents: schema.maybe(schema.boolean({ defaultValue: false })), + enableManagedLogsAndMetricsDataviews: schema.boolean({ defaultValue: true }), registryUrl: schema.maybe(schema.uri({ scheme: ['http', 'https'] })), registryProxyUrl: schema.maybe(schema.uri({ scheme: ['http', 'https'] })), agents: schema.object({ diff --git a/x-pack/platform/plugins/shared/fleet/server/services/epm/kibana/assets/install.ts b/x-pack/platform/plugins/shared/fleet/server/services/epm/kibana/assets/install.ts index 6361aa1bf935b..d5594f54300b2 100644 --- a/x-pack/platform/plugins/shared/fleet/server/services/epm/kibana/assets/install.ts +++ b/x-pack/platform/plugins/shared/fleet/server/services/epm/kibana/assets/install.ts @@ -35,6 +35,7 @@ import { withPackageSpan } from '../../packages/utils'; import { tagKibanaAssets } from './tag_assets'; import { getSpaceAwareSaveobjectsClients } from './saved_objects'; +import { appContextService } from '../../..'; const MAX_ASSETS_TO_INSTALL_IN_PARALLEL = 1000; @@ -133,8 +134,10 @@ export async function installKibanaAssets(options: { return []; } - await createDefaultIndexPatterns(savedObjectsImporter); - await makeManagedIndexPatternsGlobal(savedObjectsClient); + await installManagedIndexPattern({ + savedObjectsClient, + savedObjectsImporter, + }); return await installKibanaSavedObjects({ logger, @@ -144,6 +147,19 @@ export async function installKibanaAssets(options: { }); } +export async function installManagedIndexPattern({ + savedObjectsClient, + savedObjectsImporter, +}: { + savedObjectsClient: SavedObjectsClientContract; + savedObjectsImporter: SavedObjectsImporterContract; +}) { + if (appContextService.getConfig()?.enableManagedLogsAndMetricsDataviews === true) { + await createDefaultIndexPatterns(savedObjectsImporter); + await makeManagedIndexPatternsGlobal(savedObjectsClient); + } +} + export async function createDefaultIndexPatterns( savedObjectsImporter: SavedObjectsImporterContract ) { diff --git a/x-pack/platform/plugins/shared/fleet/server/services/epm/kibana/assets/install_with_streaming.ts b/x-pack/platform/plugins/shared/fleet/server/services/epm/kibana/assets/install_with_streaming.ts index 45c4aee73b583..b424d71b00f62 100644 --- a/x-pack/platform/plugins/shared/fleet/server/services/epm/kibana/assets/install_with_streaming.ts +++ b/x-pack/platform/plugins/shared/fleet/server/services/epm/kibana/assets/install_with_streaming.ts @@ -13,13 +13,11 @@ import { getPathParts } from '../../archive'; import { saveKibanaAssetsRefs } from '../../packages/install'; -import { makeManagedIndexPatternsGlobal } from '../index_pattern/install'; - import type { ArchiveAsset } from './install'; import { KibanaSavedObjectTypeMapping, - createDefaultIndexPatterns, createSavedObjectKibanaAsset, + installManagedIndexPattern, isKibanaAssetType, toAssetReference, } from './install'; @@ -45,8 +43,10 @@ export async function installKibanaAssetsWithStreaming({ const { savedObjectClientWithSpace, savedObjectsImporter } = getSpaceAwareSaveobjectsClients(spaceId); - await createDefaultIndexPatterns(savedObjectsImporter); - await makeManagedIndexPatternsGlobal(savedObjectsClient); + await installManagedIndexPattern({ + savedObjectsImporter, + savedObjectsClient, + }); const assetRefs: KibanaAssetReference[] = []; let batch: ArchiveAsset[] = [];