Skip to content

Commit

Permalink
[8.x] [Fleet] Allow to enable global logs and metrics dataview creati…
Browse files Browse the repository at this point in the history
…on with config enableManagedLogsAndMetricsDataviews (#205268) (#205330)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[Fleet] Allow to enable global logs and metrics dataview creation
with config enableManagedLogsAndMetricsDataviews
(#205268)](#205268)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Nicolas
Chaulet","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-12-31T15:02:10Z","message":"[Fleet]
Allow to enable global logs and metrics dataview creation with config
enableManagedLogsAndMetricsDataviews
(#205268)","sha":"dd31e406be605f8db329a9d3bf36164c1425a43c","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:Fleet","v9.0.0","backport:prev-minor"],"title":"[Fleet]
Allow to enable global logs and metrics dataview creation with config
enableManagedLogsAndMetricsDataviews","number":205268,"url":"https://github.com/elastic/kibana/pull/205268","mergeCommit":{"message":"[Fleet]
Allow to enable global logs and metrics dataview creation with config
enableManagedLogsAndMetricsDataviews
(#205268)","sha":"dd31e406be605f8db329a9d3bf36164c1425a43c"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/205268","number":205268,"mergeCommit":{"message":"[Fleet]
Allow to enable global logs and metrics dataview creation with config
enableManagedLogsAndMetricsDataviews
(#205268)","sha":"dd31e406be605f8db329a9d3bf36164c1425a43c"}}]}]
BACKPORT-->

Co-authored-by: Nicolas Chaulet <[email protected]>
  • Loading branch information
kibanamachine and nchaulet authored Dec 31, 2024
1 parent 02fe437 commit 6ecf198
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 6ecf198

Please sign in to comment.