Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fleet] Allow to enable global logs and metrics dataview creation with config enableManagedLogsAndMetricsDataviews #205268

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export interface FleetConfigType {
agentIdVerificationEnabled?: boolean;
eventIngestedEnabled?: 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
Loading