From 456316b4d95a06d07e3683842e01b66627f34984 Mon Sep 17 00:00:00 2001 From: Chris Cowan Date: Tue, 26 Nov 2024 00:29:48 -0700 Subject: [PATCH] [8.x] [EEM] Add built in definitions for core Kubernetes entities (#196916) (#201660) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # Backport This will backport the following commits from `main` to `8.x`: - [[EEM] Add built in definitions for core Kubernetes entities (#196916)](https://github.com/elastic/kibana/pull/196916) ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) Co-authored-by: Milton Hultgren --- .../server/lib/entities/built_in/index.ts | 3 ++ .../kubernetes/common/ecs_index_patterns.ts | 8 ++++ .../kubernetes/common/ecs_metadata.ts | 28 +++++++++++ .../kubernetes/common/global_metadata.ts | 26 +++++++++++ .../kubernetes/common/otel_index_patterns.ts | 8 ++++ .../kubernetes/common/otel_metadata.ts | 23 ++++++++++ .../built_in/kubernetes/ecs/cluster.ts | 46 +++++++++++++++++++ .../built_in/kubernetes/ecs/cron_job.ts | 34 ++++++++++++++ .../built_in/kubernetes/ecs/daemon_set.ts | 34 ++++++++++++++ .../built_in/kubernetes/ecs/deployment.ts | 34 ++++++++++++++ .../entities/built_in/kubernetes/ecs/index.ts | 17 +++++++ .../entities/built_in/kubernetes/ecs/job.ts | 34 ++++++++++++++ .../entities/built_in/kubernetes/ecs/node.ts | 34 ++++++++++++++ .../entities/built_in/kubernetes/ecs/pod.ts | 34 ++++++++++++++ .../built_in/kubernetes/ecs/replica_set.ts | 33 +++++++++++++ .../built_in/kubernetes/ecs/service.ts | 34 ++++++++++++++ .../built_in/kubernetes/ecs/stateful_set.ts | 34 ++++++++++++++ .../lib/entities/built_in/kubernetes/index.ts | 9 ++++ .../built_in/kubernetes/semconv/cluster.ts | 34 ++++++++++++++ .../built_in/kubernetes/semconv/cron_job.ts | 34 ++++++++++++++ .../built_in/kubernetes/semconv/daemon_set.ts | 34 ++++++++++++++ .../built_in/kubernetes/semconv/deployment.ts | 34 ++++++++++++++ .../built_in/kubernetes/semconv/index.ts | 16 +++++++ .../built_in/kubernetes/semconv/job.ts | 34 ++++++++++++++ .../built_in/kubernetes/semconv/node.ts | 34 ++++++++++++++ .../built_in/kubernetes/semconv/pod.ts | 34 ++++++++++++++ .../kubernetes/semconv/replica_set.ts | 34 ++++++++++++++ .../kubernetes/semconv/stateful_set.ts | 34 ++++++++++++++ .../entities/uninstall_entity_definition.ts | 5 +- .../apis/entity_manager/helpers/request.ts | 6 +-- 30 files changed, 802 insertions(+), 4 deletions(-) create mode 100644 x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/common/ecs_index_patterns.ts create mode 100644 x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/common/ecs_metadata.ts create mode 100644 x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/common/global_metadata.ts create mode 100644 x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/common/otel_index_patterns.ts create mode 100644 x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/common/otel_metadata.ts create mode 100644 x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/ecs/cluster.ts create mode 100644 x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/ecs/cron_job.ts create mode 100644 x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/ecs/daemon_set.ts create mode 100644 x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/ecs/deployment.ts create mode 100644 x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/ecs/index.ts create mode 100644 x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/ecs/job.ts create mode 100644 x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/ecs/node.ts create mode 100644 x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/ecs/pod.ts create mode 100644 x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/ecs/replica_set.ts create mode 100644 x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/ecs/service.ts create mode 100644 x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/ecs/stateful_set.ts create mode 100644 x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/index.ts create mode 100644 x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/semconv/cluster.ts create mode 100644 x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/semconv/cron_job.ts create mode 100644 x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/semconv/daemon_set.ts create mode 100644 x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/semconv/deployment.ts create mode 100644 x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/semconv/index.ts create mode 100644 x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/semconv/job.ts create mode 100644 x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/semconv/node.ts create mode 100644 x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/semconv/pod.ts create mode 100644 x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/semconv/replica_set.ts create mode 100644 x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/semconv/stateful_set.ts diff --git a/x-pack/plugins/entity_manager/server/lib/entities/built_in/index.ts b/x-pack/plugins/entity_manager/server/lib/entities/built_in/index.ts index 6c0d4c5995c63..6b1c384f5b541 100644 --- a/x-pack/plugins/entity_manager/server/lib/entities/built_in/index.ts +++ b/x-pack/plugins/entity_manager/server/lib/entities/built_in/index.ts @@ -10,10 +10,13 @@ import { builtInServicesFromEcsEntityDefinition } from './services_from_ecs_data import { builtInHostsFromEcsEntityDefinition } from './hosts_from_ecs_data'; import { builtInContainersFromEcsEntityDefinition } from './containers_from_ecs_data'; +import * as kubernetes from './kubernetes'; + export { BUILT_IN_ID_PREFIX } from './constants'; export const builtInDefinitions: EntityDefinition[] = [ builtInServicesFromEcsEntityDefinition, builtInHostsFromEcsEntityDefinition, builtInContainersFromEcsEntityDefinition, + ...Object.values(kubernetes), ]; diff --git a/x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/common/ecs_index_patterns.ts b/x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/common/ecs_index_patterns.ts new file mode 100644 index 0000000000000..14e2766cac2b2 --- /dev/null +++ b/x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/common/ecs_index_patterns.ts @@ -0,0 +1,8 @@ +/* + * 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. + */ + +export const commonEcsIndexPatterns = ['metrics-kubernetes*', 'logs-*']; diff --git a/x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/common/ecs_metadata.ts b/x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/common/ecs_metadata.ts new file mode 100644 index 0000000000000..5995b4aa46d5f --- /dev/null +++ b/x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/common/ecs_metadata.ts @@ -0,0 +1,28 @@ +/* + * 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 { MetadataField } from '@kbn/entities-schema'; +import { globalMetadata } from './global_metadata'; + +export const commonEcsMetadata: MetadataField[] = [ + ...globalMetadata, + { + source: 'orchestrator.namespace', + destination: 'orchestrator.namespace', + aggregation: { type: 'terms', limit: 10 }, + }, + { + source: 'orchestrator.cluster_ip', + destination: 'orchestrator.cluster_id', + aggregation: { type: 'top_value', sort: { '@timestamp': 'desc' } }, + }, + { + source: 'orchestrator.cluster_name', + destination: 'orchestrator.cluster_name', + aggregation: { type: 'top_value', sort: { '@timestamp': 'desc' } }, + }, +]; diff --git a/x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/common/global_metadata.ts b/x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/common/global_metadata.ts new file mode 100644 index 0000000000000..bc7c8fc03a930 --- /dev/null +++ b/x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/common/global_metadata.ts @@ -0,0 +1,26 @@ +/* + * 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 { MetadataField } from '@kbn/entities-schema'; + +export const globalMetadata: MetadataField[] = [ + { + source: '_index', + destination: 'source_index', + aggregation: { type: 'top_value', sort: { '@timestamp': 'desc' } }, + }, + { + source: 'data_stream.type', + destination: 'source_data_stream.type', + aggregation: { type: 'top_value', sort: { '@timestamp': 'desc' } }, + }, + { + source: 'data_stream.dataset', + destination: 'source_data_stream.dataset', + aggregation: { type: 'top_value', sort: { '@timestamp': 'desc' } }, + }, +]; diff --git a/x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/common/otel_index_patterns.ts b/x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/common/otel_index_patterns.ts new file mode 100644 index 0000000000000..9978f61efafab --- /dev/null +++ b/x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/common/otel_index_patterns.ts @@ -0,0 +1,8 @@ +/* + * 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. + */ + +export const commonOtelIndexPatterns = ['metrics-*otel*', 'logs-*']; diff --git a/x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/common/otel_metadata.ts b/x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/common/otel_metadata.ts new file mode 100644 index 0000000000000..946f5cc4ead43 --- /dev/null +++ b/x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/common/otel_metadata.ts @@ -0,0 +1,23 @@ +/* + * 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 { MetadataField } from '@kbn/entities-schema'; +import { globalMetadata } from './global_metadata'; + +export const commonOtelMetadata: MetadataField[] = [ + ...globalMetadata, + { + source: 'k8s.namespace.name', + destination: 'k8s.namespace.name', + aggregation: { type: 'terms', limit: 10 }, + }, + { + source: 'k8s.cluster.name', + destination: 'k8s.cluster.name', + aggregation: { type: 'top_value', sort: { '@timestamp': 'desc' } }, + }, +]; diff --git a/x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/ecs/cluster.ts b/x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/ecs/cluster.ts new file mode 100644 index 0000000000000..1d452b8a8620e --- /dev/null +++ b/x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/ecs/cluster.ts @@ -0,0 +1,46 @@ +/* + * 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 { EntityDefinition, entityDefinitionSchema } from '@kbn/entities-schema'; +import { BUILT_IN_ID_PREFIX } from '../../constants'; +import { commonEcsIndexPatterns } from '../common/ecs_index_patterns'; +import { globalMetadata } from '../common/global_metadata'; + +export const builtInKubernetesClusterEcsEntityDefinition: EntityDefinition = + entityDefinitionSchema.parse({ + id: `${BUILT_IN_ID_PREFIX}kubernetes_cluster_ecs`, + filter: 'orchestrator.cluster.name: *', + managed: true, + version: '0.1.0', + name: 'Kubernetes Clusters from ECS data', + description: + 'This definition extracts Kubernetes cluster entities from the Kubernetes integration data streams', + type: 'k8s.cluster.ecs', + indexPatterns: commonEcsIndexPatterns, + identityFields: ['orchestrator.cluster.name'], + displayNameTemplate: '{{orchestrator.cluster.name}}', + latest: { + timestampField: '@timestamp', + lookbackPeriod: '10m', + settings: { + frequency: '5m', + }, + }, + metadata: [ + ...globalMetadata, + { + source: 'orchestrator.namespace', + destination: 'orchestrator.namespace', + aggregation: { type: 'terms', limit: 10 }, + }, + { + source: 'orchestrator.cluster_ip', + destination: 'orchestrator.cluster_id', + aggregation: { type: 'top_value', sort: { '@timestamp': 'desc' } }, + }, + ], + }); diff --git a/x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/ecs/cron_job.ts b/x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/ecs/cron_job.ts new file mode 100644 index 0000000000000..7849dcdc73f5b --- /dev/null +++ b/x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/ecs/cron_job.ts @@ -0,0 +1,34 @@ +/* + * 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 { EntityDefinition, entityDefinitionSchema } from '@kbn/entities-schema'; +import { BUILT_IN_ID_PREFIX } from '../../constants'; +import { commonEcsIndexPatterns } from '../common/ecs_index_patterns'; +import { commonEcsMetadata } from '../common/ecs_metadata'; + +export const builtInKubernetesCronJobEcsEntityDefinition: EntityDefinition = + entityDefinitionSchema.parse({ + id: `${BUILT_IN_ID_PREFIX}kubernetes_cron_job_ecs`, + filter: 'kubernetes.cronjob.uid : *', + managed: true, + version: '0.1.0', + name: 'Kubernetes CronJob from ECS data', + description: + 'This definition extracts Kubernetes cron job entities from the Kubernetes integration data streams', + type: 'k8s.cronjob.ecs', + indexPatterns: commonEcsIndexPatterns, + identityFields: ['kubernetes.cronjob.uid'], + displayNameTemplate: '{{kubernetes.cronjob.name}}', + latest: { + timestampField: '@timestamp', + lookbackPeriod: '10m', + settings: { + frequency: '5m', + }, + }, + metadata: commonEcsMetadata, + }); diff --git a/x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/ecs/daemon_set.ts b/x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/ecs/daemon_set.ts new file mode 100644 index 0000000000000..5b57cdd6ae2f8 --- /dev/null +++ b/x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/ecs/daemon_set.ts @@ -0,0 +1,34 @@ +/* + * 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 { EntityDefinition, entityDefinitionSchema } from '@kbn/entities-schema'; +import { BUILT_IN_ID_PREFIX } from '../../constants'; +import { commonEcsIndexPatterns } from '../common/ecs_index_patterns'; +import { commonEcsMetadata } from '../common/ecs_metadata'; + +export const builtInKubernetesDaemonSetEcsEntityDefinition: EntityDefinition = + entityDefinitionSchema.parse({ + id: `${BUILT_IN_ID_PREFIX}kubernetes_daemon_set_ecs`, + filter: 'kubernetes.daemonset.uid : *', + managed: true, + version: '0.1.0', + name: 'Kubernetes DaemonSet from ECS data', + description: + 'This definition extracts Kubernetes daemon set entities from the Kubernetes integration data streams', + type: 'k8s.daemonset.ecs', + indexPatterns: commonEcsIndexPatterns, + identityFields: ['kubernetes.daemonset.name'], + displayNameTemplate: '{{kubernetes.daemonset.name}}', + latest: { + timestampField: '@timestamp', + lookbackPeriod: '10m', + settings: { + frequency: '5m', + }, + }, + metadata: commonEcsMetadata, + }); diff --git a/x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/ecs/deployment.ts b/x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/ecs/deployment.ts new file mode 100644 index 0000000000000..d33c14db7e2c9 --- /dev/null +++ b/x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/ecs/deployment.ts @@ -0,0 +1,34 @@ +/* + * 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 { EntityDefinition, entityDefinitionSchema } from '@kbn/entities-schema'; +import { BUILT_IN_ID_PREFIX } from '../../constants'; +import { commonEcsMetadata } from '../common/ecs_metadata'; +import { commonEcsIndexPatterns } from '../common/ecs_index_patterns'; + +export const builtInKubernetesDeploymentEcsEntityDefinition: EntityDefinition = + entityDefinitionSchema.parse({ + id: `${BUILT_IN_ID_PREFIX}kubernetes_deployment_ecs`, + filter: 'kubernetes.deployment.uid : *', + managed: true, + version: '0.1.0', + name: 'Kubernetes Deployment from ECS data', + description: + 'This definition extracts Kubernetes deployment entities from the Kubernetes integration data streams', + type: 'k8s.deployment.ecs', + indexPatterns: commonEcsIndexPatterns, + identityFields: ['kubernetes.deployment.uid'], + displayNameTemplate: '{{kubernetes.deployment.name}}', + latest: { + timestampField: '@timestamp', + lookbackPeriod: '10m', + settings: { + frequency: '5m', + }, + }, + metadata: commonEcsMetadata, + }); diff --git a/x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/ecs/index.ts b/x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/ecs/index.ts new file mode 100644 index 0000000000000..ecfa67ff893ba --- /dev/null +++ b/x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/ecs/index.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; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +export { builtInKubernetesClusterEcsEntityDefinition } from './cluster'; +export { builtInKubernetesNodeEcsEntityDefinition } from './node'; +export { builtInKubernetesPodEcsEntityDefinition } from './pod'; +export { builtInKubernetesReplicaSetEcsEntityDefinition } from './replica_set'; +export { builtInKubernetesDeploymentEcsEntityDefinition } from './deployment'; +export { builtInKubernetesStatefulSetEcsEntityDefinition } from './stateful_set'; +export { builtInKubernetesDaemonSetEcsEntityDefinition } from './daemon_set'; +export { builtInKubernetesJobEcsEntityDefinition } from './job'; +export { builtInKubernetesCronJobEcsEntityDefinition } from './cron_job'; +export { builtInKubernetesServiceEcsEntityDefinition } from './service'; diff --git a/x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/ecs/job.ts b/x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/ecs/job.ts new file mode 100644 index 0000000000000..92c6d13251553 --- /dev/null +++ b/x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/ecs/job.ts @@ -0,0 +1,34 @@ +/* + * 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 { EntityDefinition, entityDefinitionSchema } from '@kbn/entities-schema'; +import { BUILT_IN_ID_PREFIX } from '../../constants'; +import { commonEcsIndexPatterns } from '../common/ecs_index_patterns'; +import { commonEcsMetadata } from '../common/ecs_metadata'; + +export const builtInKubernetesJobEcsEntityDefinition: EntityDefinition = + entityDefinitionSchema.parse({ + id: `${BUILT_IN_ID_PREFIX}kubernetes_job_ecs`, + filter: 'kubernetes.job.uid : *', + managed: true, + version: '0.1.0', + name: 'Kubernetes Job from ECS data', + description: + 'This definition extracts Kubernetes job entities from the Kubernetes integration data streams', + type: 'k8s.job.ecs', + indexPatterns: commonEcsIndexPatterns, + identityFields: ['kubernetes.job.uid'], + displayNameTemplate: '{{kubernetes.job.name}}', + latest: { + timestampField: '@timestamp', + lookbackPeriod: '10m', + settings: { + frequency: '5m', + }, + }, + metadata: commonEcsMetadata, + }); diff --git a/x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/ecs/node.ts b/x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/ecs/node.ts new file mode 100644 index 0000000000000..f3fdcdfaf04b4 --- /dev/null +++ b/x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/ecs/node.ts @@ -0,0 +1,34 @@ +/* + * 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 { EntityDefinition, entityDefinitionSchema } from '@kbn/entities-schema'; +import { BUILT_IN_ID_PREFIX } from '../../constants'; +import { commonEcsIndexPatterns } from '../common/ecs_index_patterns'; +import { commonEcsMetadata } from '../common/ecs_metadata'; + +export const builtInKubernetesNodeEcsEntityDefinition: EntityDefinition = + entityDefinitionSchema.parse({ + id: `${BUILT_IN_ID_PREFIX}kubernetes_node_ecs`, + filer: 'kubernetes.node.uid : *', + managed: true, + version: '0.1.0', + name: 'Kubernetes Node from ECS data', + description: + 'This definition extracts Kubernetes node entities from the Kubernetes integration data streams', + type: 'k8s.node.ecs', + indexPatterns: commonEcsIndexPatterns, + identityFields: ['kubernetes.node.uid'], + displayNameTemplate: '{{kubernetes.node.name}}', + latest: { + timestampField: '@timestamp', + lookbackPeriod: '10m', + settings: { + frequency: '5m', + }, + }, + metadata: commonEcsMetadata, + }); diff --git a/x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/ecs/pod.ts b/x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/ecs/pod.ts new file mode 100644 index 0000000000000..7aa53da6e5a7d --- /dev/null +++ b/x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/ecs/pod.ts @@ -0,0 +1,34 @@ +/* + * 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 { EntityDefinition, entityDefinitionSchema } from '@kbn/entities-schema'; +import { BUILT_IN_ID_PREFIX } from '../../constants'; +import { commonEcsMetadata } from '../common/ecs_metadata'; +import { commonEcsIndexPatterns } from '../common/ecs_index_patterns'; + +export const builtInKubernetesPodEcsEntityDefinition: EntityDefinition = + entityDefinitionSchema.parse({ + id: `${BUILT_IN_ID_PREFIX}kubernetes_pod_ecs`, + filter: 'kubernetes.pod.uid: *', + managed: true, + version: '0.1.0', + name: 'Kubernetes Pod from ECS data', + description: + 'This definition extracts Kubernetes pod entities from the Kubernetes integration data streams', + type: 'k8s.pod.ecs', + indexPatterns: commonEcsIndexPatterns, + identityFields: ['kubernetes.pod.name'], + displayNameTemplate: '{{kubernetes.pod.name}}', + latest: { + timestampField: '@timestamp', + lookbackPeriod: '10m', + settings: { + frequency: '5m', + }, + }, + metadata: commonEcsMetadata, + }); diff --git a/x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/ecs/replica_set.ts b/x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/ecs/replica_set.ts new file mode 100644 index 0000000000000..cc059c14979d0 --- /dev/null +++ b/x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/ecs/replica_set.ts @@ -0,0 +1,33 @@ +/* + * 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 { EntityDefinition, entityDefinitionSchema } from '@kbn/entities-schema'; +import { BUILT_IN_ID_PREFIX } from '../../constants'; +import { commonEcsMetadata } from '../common/ecs_metadata'; +import { commonEcsIndexPatterns } from '../common/ecs_index_patterns'; + +export const builtInKubernetesReplicaSetEcsEntityDefinition: EntityDefinition = + entityDefinitionSchema.parse({ + id: `${BUILT_IN_ID_PREFIX}kubernetes_replica_set_ecs`, + managed: true, + version: '0.1.0', + name: 'Kubernetes ReplicaSet from ECS data', + description: + 'This definition extracts Kubernetes replica set entities from the Kubernetes integration data streams', + type: 'k8s.replicaset.ecs', + indexPatterns: commonEcsIndexPatterns, + identityFields: ['kubernetes.replicaset.uid'], + displayNameTemplate: '{{kubernetes.replicaset.name}}', + latest: { + timestampField: '@timestamp', + lookbackPeriod: '10m', + settings: { + frequency: '5m', + }, + }, + metadata: commonEcsMetadata, + }); diff --git a/x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/ecs/service.ts b/x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/ecs/service.ts new file mode 100644 index 0000000000000..be1b3b7c6b1c4 --- /dev/null +++ b/x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/ecs/service.ts @@ -0,0 +1,34 @@ +/* + * 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 { EntityDefinition, entityDefinitionSchema } from '@kbn/entities-schema'; +import { BUILT_IN_ID_PREFIX } from '../../constants'; +import { commonEcsMetadata } from '../common/ecs_metadata'; +import { commonEcsIndexPatterns } from '../common/ecs_index_patterns'; + +export const builtInKubernetesServiceEcsEntityDefinition: EntityDefinition = + entityDefinitionSchema.parse({ + id: `${BUILT_IN_ID_PREFIX}kubernetes_service_ecs`, + filter: 'kubernetes.service.name: *', + managed: true, + version: '0.1.0', + name: 'Kubernetes Services from ECS data', + description: + 'This definition extracts Kubernetes service entities from the Kubernetes integration data streams', + type: 'k8s.service.ecs', + indexPatterns: commonEcsIndexPatterns, + identityFields: ['kubernetes.service.name'], + displayNameTemplate: '{{kubernetes.service.name}}', + latest: { + timestampField: '@timestamp', + lookbackPeriod: '10m', + settings: { + frequency: '5m', + }, + }, + metadata: commonEcsMetadata, + }); diff --git a/x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/ecs/stateful_set.ts b/x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/ecs/stateful_set.ts new file mode 100644 index 0000000000000..79f9d4489216f --- /dev/null +++ b/x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/ecs/stateful_set.ts @@ -0,0 +1,34 @@ +/* + * 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 { EntityDefinition, entityDefinitionSchema } from '@kbn/entities-schema'; +import { BUILT_IN_ID_PREFIX } from '../../constants'; +import { commonEcsMetadata } from '../common/ecs_metadata'; +import { commonEcsIndexPatterns } from '../common/ecs_index_patterns'; + +export const builtInKubernetesStatefulSetEcsEntityDefinition: EntityDefinition = + entityDefinitionSchema.parse({ + id: `${BUILT_IN_ID_PREFIX}kubernetes_stateful_set_ecs`, + filter: 'kubernetes.statefulset.uid : *', + managed: true, + version: '0.1.0', + name: 'Kubernetes StatefulSet from ECS data', + description: + 'This definition extracts Kubernetes stateful set entities from the Kubernetes integration data streams', + type: 'k8s.statefulset.ecs', + indexPatterns: commonEcsIndexPatterns, + identityFields: ['kubernetes.statefulset.uid'], + displayNameTemplate: '{{kubernetes.statefulset.name}}', + latest: { + timestampField: '@timestamp', + lookbackPeriod: '10m', + settings: { + frequency: '5m', + }, + }, + metadata: commonEcsMetadata, + }); diff --git a/x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/index.ts b/x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/index.ts new file mode 100644 index 0000000000000..fa559fb86d9db --- /dev/null +++ b/x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/index.ts @@ -0,0 +1,9 @@ +/* + * 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. + */ + +export * from './ecs'; +export * from './semconv'; diff --git a/x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/semconv/cluster.ts b/x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/semconv/cluster.ts new file mode 100644 index 0000000000000..0ec244ec617f3 --- /dev/null +++ b/x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/semconv/cluster.ts @@ -0,0 +1,34 @@ +/* + * 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 { EntityDefinition, entityDefinitionSchema } from '@kbn/entities-schema'; +import { BUILT_IN_ID_PREFIX } from '../../constants'; +import { commonOtelIndexPatterns } from '../common/otel_index_patterns'; +import { commonOtelMetadata } from '../common/otel_metadata'; + +export const builtInKubernetesClusterSemConvEntityDefinition: EntityDefinition = + entityDefinitionSchema.parse({ + id: `${BUILT_IN_ID_PREFIX}kubernetes_cluster_semconv`, + filter: 'k8s.cluster.uid: *', + managed: true, + version: '0.1.0', + name: 'Kubernetes Clusters from SemConv data', + description: + 'This definition extracts Kubernetes cluster entities using data collected with OpenTelemetry', + type: 'kubernetes_cluster_semconv', + indexPatterns: commonOtelIndexPatterns, + identityFields: ['k8s.cluster.uid'], + displayNameTemplate: '{{k8s.cluster.name}}', + latest: { + timestampField: '@timestamp', + lookbackPeriod: '10m', + settings: { + frequency: '5m', + }, + }, + metadata: commonOtelMetadata, + }); diff --git a/x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/semconv/cron_job.ts b/x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/semconv/cron_job.ts new file mode 100644 index 0000000000000..6d677943976d1 --- /dev/null +++ b/x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/semconv/cron_job.ts @@ -0,0 +1,34 @@ +/* + * 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 { EntityDefinition, entityDefinitionSchema } from '@kbn/entities-schema'; +import { BUILT_IN_ID_PREFIX } from '../../constants'; +import { commonOtelIndexPatterns } from '../common/otel_index_patterns'; +import { commonOtelMetadata } from '../common/otel_metadata'; + +export const builtInKubernetesCronJobSemConvEntityDefinition: EntityDefinition = + entityDefinitionSchema.parse({ + id: `${BUILT_IN_ID_PREFIX}kubernetes_cron_job_semconv`, + filter: 'k8s.cronjob.uid : *', + managed: true, + version: '0.1.0', + name: 'Kubernetes CronJob from SemConv data', + description: + 'This definition extracts Kubernetes cron job entities using data collected with OpenTelemetry', + type: 'k8s.cronjob.otel', + indexPatterns: commonOtelIndexPatterns, + identityFields: ['k8s.cronjob.uid'], + displayNameTemplate: '{{k8s.cronjob.name}}', + latest: { + timestampField: '@timestamp', + lookbackPeriod: '10m', + settings: { + frequency: '5m', + }, + }, + metadata: commonOtelMetadata, + }); diff --git a/x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/semconv/daemon_set.ts b/x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/semconv/daemon_set.ts new file mode 100644 index 0000000000000..a4b61933ad316 --- /dev/null +++ b/x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/semconv/daemon_set.ts @@ -0,0 +1,34 @@ +/* + * 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 { EntityDefinition, entityDefinitionSchema } from '@kbn/entities-schema'; +import { BUILT_IN_ID_PREFIX } from '../../constants'; +import { commonOtelIndexPatterns } from '../common/otel_index_patterns'; +import { commonOtelMetadata } from '../common/otel_metadata'; + +export const builtInKubernetesDaemonSetSemConvEntityDefinition: EntityDefinition = + entityDefinitionSchema.parse({ + id: `${BUILT_IN_ID_PREFIX}kubernetes_daemon_set_semconv`, + filter: 'k8s.daemonset.uid : *', + managed: true, + version: '0.1.0', + name: 'Kubernetes DaemonSet from SemConv data', + description: + 'This definition extracts Kubernetes daemon set entities using data collected with OpenTelemetry', + type: 'k8s.daemonset.otel', + indexPatterns: commonOtelIndexPatterns, + identityFields: ['k8s.daemonset.uid'], + displayNameTemplate: '{{k8s.daemonset.name}}', + latest: { + timestampField: '@timestamp', + lookbackPeriod: '10m', + settings: { + frequency: '5m', + }, + }, + metadata: commonOtelMetadata, + }); diff --git a/x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/semconv/deployment.ts b/x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/semconv/deployment.ts new file mode 100644 index 0000000000000..bdb3cb1cef59b --- /dev/null +++ b/x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/semconv/deployment.ts @@ -0,0 +1,34 @@ +/* + * 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 { EntityDefinition, entityDefinitionSchema } from '@kbn/entities-schema'; +import { BUILT_IN_ID_PREFIX } from '../../constants'; +import { commonOtelMetadata } from '../common/otel_metadata'; +import { commonOtelIndexPatterns } from '../common/otel_index_patterns'; + +export const builtInKubernetesDeploymentSemConvEntityDefinition: EntityDefinition = + entityDefinitionSchema.parse({ + id: `${BUILT_IN_ID_PREFIX}kubernetes_deployment_semconv`, + filter: 'k8s.deployment.uid : *', + managed: true, + version: '0.1.0', + name: 'Kubernetes Deployment from SemConv data', + description: + 'This definition extracts Kubernetes deployment entities using data collected with OpenTelemetry', + type: 'k8s.deployment.otel', + indexPatterns: commonOtelIndexPatterns, + identityFields: ['k8s.deployment.uid'], + displayNameTemplate: '{{k8s.deployment.name}}', + latest: { + timestampField: '@timestamp', + lookbackPeriod: '10m', + settings: { + frequency: '5m', + }, + }, + metadata: commonOtelMetadata, + }); diff --git a/x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/semconv/index.ts b/x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/semconv/index.ts new file mode 100644 index 0000000000000..fbfcd9c5f9024 --- /dev/null +++ b/x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/semconv/index.ts @@ -0,0 +1,16 @@ +/* + * 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. + */ + +export { builtInKubernetesClusterSemConvEntityDefinition } from './cluster'; +export { builtInKubernetesNodeSemConvEntityDefinition } from './node'; +export { builtInKubernetesPodSemConvEntityDefinition } from './pod'; +export { builtInKubernetesReplicaSetSemConvEntityDefinition } from './replica_set'; +export { builtInKubernetesDeploymentSemConvEntityDefinition } from './deployment'; +export { builtInKubernetesStatefulSetSemConvEntityDefinition } from './stateful_set'; +export { builtInKubernetesDaemonSetSemConvEntityDefinition } from './daemon_set'; +export { builtInKubernetesJobSemConvEntityDefinition } from './job'; +export { builtInKubernetesCronJobSemConvEntityDefinition } from './cron_job'; diff --git a/x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/semconv/job.ts b/x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/semconv/job.ts new file mode 100644 index 0000000000000..b2e48cf7494fb --- /dev/null +++ b/x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/semconv/job.ts @@ -0,0 +1,34 @@ +/* + * 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 { EntityDefinition, entityDefinitionSchema } from '@kbn/entities-schema'; +import { BUILT_IN_ID_PREFIX } from '../../constants'; +import { commonOtelIndexPatterns } from '../common/otel_index_patterns'; +import { commonOtelMetadata } from '../common/otel_metadata'; + +export const builtInKubernetesJobSemConvEntityDefinition: EntityDefinition = + entityDefinitionSchema.parse({ + id: `${BUILT_IN_ID_PREFIX}kubernetes_job_semconv`, + filter: 'k8s.job.uid : *', + managed: true, + version: '0.1.0', + name: 'Kubernetes Job from SemConv data', + description: + 'This definition extracts Kubernetes job entities using data collected with OpenTelemetry', + type: 'k8s.job.otel', + indexPatterns: commonOtelIndexPatterns, + identityFields: ['k8s.job.uid'], + displayNameTemplate: '{{k8s.job.name}}', + latest: { + timestampField: '@timestamp', + lookbackPeriod: '10m', + settings: { + frequency: '5m', + }, + }, + metadata: commonOtelMetadata, + }); diff --git a/x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/semconv/node.ts b/x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/semconv/node.ts new file mode 100644 index 0000000000000..456f030421075 --- /dev/null +++ b/x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/semconv/node.ts @@ -0,0 +1,34 @@ +/* + * 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 { EntityDefinition, entityDefinitionSchema } from '@kbn/entities-schema'; +import { BUILT_IN_ID_PREFIX } from '../../constants'; +import { commonOtelIndexPatterns } from '../common/otel_index_patterns'; +import { commonOtelMetadata } from '../common/otel_metadata'; + +export const builtInKubernetesNodeSemConvEntityDefinition: EntityDefinition = + entityDefinitionSchema.parse({ + id: `${BUILT_IN_ID_PREFIX}kubernetes_node_semconv`, + filter: 'k8s.node.uid: *', + managed: true, + version: '0.1.0', + name: 'Kubernetes Node from SemConv data', + description: + 'This definition extracts Kubernetes node entities using data collected with OpenTelemetry', + type: 'k8s.node.otel', + indexPatterns: commonOtelIndexPatterns, + identityFields: ['k8s.node.uid'], + displayNameTemplate: '{{k8s.node.uid}}', + latest: { + timestampField: '@timestamp', + lookbackPeriod: '10m', + settings: { + frequency: '5m', + }, + }, + metadata: commonOtelMetadata, + }); diff --git a/x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/semconv/pod.ts b/x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/semconv/pod.ts new file mode 100644 index 0000000000000..6dc879d761dd8 --- /dev/null +++ b/x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/semconv/pod.ts @@ -0,0 +1,34 @@ +/* + * 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 { EntityDefinition, entityDefinitionSchema } from '@kbn/entities-schema'; +import { BUILT_IN_ID_PREFIX } from '../../constants'; +import { commonOtelMetadata } from '../common/otel_metadata'; +import { commonOtelIndexPatterns } from '../common/otel_index_patterns'; + +export const builtInKubernetesPodSemConvEntityDefinition: EntityDefinition = + entityDefinitionSchema.parse({ + id: `${BUILT_IN_ID_PREFIX}kubernetes_pod_semconv`, + filter: 'k8s.pod.uid : *', + managed: true, + version: '0.1.0', + name: 'Kubernetes Pod from SemConv data', + description: + 'This definition extracts Kubernetes pod entities using data collected with OpenTelemetry', + type: 'k8s.pod.otel', + indexPatterns: commonOtelIndexPatterns, + identityFields: ['k8s.pod.uid'], + displayNameTemplate: '{{k8s.pod.name}}', + latest: { + timestampField: '@timestamp', + lookbackPeriod: '10m', + settings: { + frequency: '5m', + }, + }, + metadata: commonOtelMetadata, + }); diff --git a/x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/semconv/replica_set.ts b/x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/semconv/replica_set.ts new file mode 100644 index 0000000000000..47bad6bf8a641 --- /dev/null +++ b/x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/semconv/replica_set.ts @@ -0,0 +1,34 @@ +/* + * 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 { EntityDefinition, entityDefinitionSchema } from '@kbn/entities-schema'; +import { BUILT_IN_ID_PREFIX } from '../../constants'; +import { commonOtelMetadata } from '../common/otel_metadata'; +import { commonOtelIndexPatterns } from '../common/otel_index_patterns'; + +export const builtInKubernetesReplicaSetSemConvEntityDefinition: EntityDefinition = + entityDefinitionSchema.parse({ + id: `${BUILT_IN_ID_PREFIX}kubernetes_replica_set_semconv`, + filter: 'k8s.replicaset.uid : *', + managed: true, + version: '0.1.0', + name: 'Kubernetes ReplicaSet from SemConv data', + description: + 'This definition extracts Kubernetes replica set entities using data collected with OpenTelemetry', + type: 'kubernetes_replica_set_semconv', + indexPatterns: commonOtelIndexPatterns, + identityFields: ['k8s.replicaset.name'], + displayNameTemplate: '{{k8s.replicaset.name}}', + latest: { + timestampField: '@timestamp', + lookbackPeriod: '10m', + settings: { + frequency: '5m', + }, + }, + metadata: commonOtelMetadata, + }); diff --git a/x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/semconv/stateful_set.ts b/x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/semconv/stateful_set.ts new file mode 100644 index 0000000000000..c61d7e5d965cd --- /dev/null +++ b/x-pack/plugins/entity_manager/server/lib/entities/built_in/kubernetes/semconv/stateful_set.ts @@ -0,0 +1,34 @@ +/* + * 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 { EntityDefinition, entityDefinitionSchema } from '@kbn/entities-schema'; +import { BUILT_IN_ID_PREFIX } from '../../constants'; +import { commonOtelMetadata } from '../common/otel_metadata'; +import { commonOtelIndexPatterns } from '../common/otel_index_patterns'; + +export const builtInKubernetesStatefulSetSemConvEntityDefinition: EntityDefinition = + entityDefinitionSchema.parse({ + id: `${BUILT_IN_ID_PREFIX}kubernetes_stateful_set_semconv`, + filter: 'k8s.statefulset.uid : *', + managed: true, + version: '0.1.0', + name: 'Kubernetes StatefulSet from SemConv data', + description: + 'This definition extracts Kubernetes stateful set entities using data collected with OpenTelemetry', + type: 'k8s.statefulset.otel', + indexPatterns: commonOtelIndexPatterns, + identityFields: ['k8s.statefulset.uid'], + displayNameTemplate: '{{k8s.statefulset.name}}', + latest: { + timestampField: '@timestamp', + lookbackPeriod: '10m', + settings: { + frequency: '5m', + }, + }, + metadata: commonOtelMetadata, + }); diff --git a/x-pack/plugins/entity_manager/server/lib/entities/uninstall_entity_definition.ts b/x-pack/plugins/entity_manager/server/lib/entities/uninstall_entity_definition.ts index f8e27353082d0..e0d7b0c9eed3d 100644 --- a/x-pack/plugins/entity_manager/server/lib/entities/uninstall_entity_definition.ts +++ b/x-pack/plugins/entity_manager/server/lib/entities/uninstall_entity_definition.ts @@ -47,7 +47,10 @@ export async function uninstallBuiltInEntityDefinitions({ entityClient: EntityClient; deleteData?: boolean; }): Promise { - const { definitions } = await entityClient.getEntityDefinitions({ builtIn: true }); + const { definitions } = await entityClient.getEntityDefinitions({ + builtIn: true, + perPage: 1000, + }); await Promise.all( definitions.map(async ({ id }) => { diff --git a/x-pack/test/api_integration/apis/entity_manager/helpers/request.ts b/x-pack/test/api_integration/apis/entity_manager/helpers/request.ts index 8eb99ca1fe371..c21f33cc8793a 100644 --- a/x-pack/test/api_integration/apis/entity_manager/helpers/request.ts +++ b/x-pack/test/api_integration/apis/entity_manager/helpers/request.ts @@ -16,12 +16,12 @@ export interface Auth { export const getInstalledDefinitions = async ( supertest: Agent, - params: { auth?: Auth; id?: string; includeState?: boolean } = {} + params: { auth?: Auth; id?: string; includeState?: boolean; perPage?: number } = {} ): Promise<{ definitions: EntityDefinitionWithState[] }> => { - const { auth, id, includeState = true } = params; + const { auth, id, includeState = true, perPage = 1000 } = params; let req = supertest .get(`/internal/entities/definition${id ? `/${id}` : ''}`) - .query({ includeState }) + .query({ includeState, perPage }) .set('kbn-xsrf', 'xxx'); if (auth) { req = req.auth(auth.username, auth.password);