Skip to content

Commit

Permalink
[Fleet] Allow to enable global logs and metrics dataview creation wit…
Browse files Browse the repository at this point in the history
…h config enableManagedLogsAndMetricsDataviews (elastic#205268)

(cherry picked from commit dd31e40)
  • Loading branch information
nchaulet committed Dec 31, 2024
1 parent 13aed70 commit 3574495
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 7 deletions.
3 changes: 3 additions & 0 deletions docs/settings/fleet-settings.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -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.

1 change: 1 addition & 0 deletions x-pack/platform/plugins/shared/fleet/common/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export interface FleetConfigType {
outputs?: PreconfiguredOutput[];
agentIdVerificationEnabled?: boolean;
enableExperimental?: string[];
enableManagedLogsAndMetricsDataviews?: boolean;
packageVerification?: {
gpgKeyPath?: string;
};
Expand Down
1 change: 1 addition & 0 deletions x-pack/platform/plugins/shared/fleet/server/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -133,8 +134,10 @@ export async function installKibanaAssets(options: {
return [];
}

await createDefaultIndexPatterns(savedObjectsImporter);
await makeManagedIndexPatternsGlobal(savedObjectsClient);
await installManagedIndexPattern({
savedObjectsClient,
savedObjectsImporter,
});

return await installKibanaSavedObjects({
logger,
Expand All @@ -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
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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[] = [];
Expand Down

0 comments on commit 3574495

Please sign in to comment.