diff --git a/packages/kbn-apm-synthtrace-client/src/lib/entities/index.ts b/packages/kbn-apm-synthtrace-client/src/lib/entities/index.ts index 10cf982ff41ee..4242476735a11 100644 --- a/packages/kbn-apm-synthtrace-client/src/lib/entities/index.ts +++ b/packages/kbn-apm-synthtrace-client/src/lib/entities/index.ts @@ -11,8 +11,19 @@ import { Fields } from '../entity'; import { serviceEntity } from './service_entity'; import { hostEntity } from './host_entity'; import { containerEntity } from './container_entity'; +import { k8sClusterJobEntity } from './kubernetes/cluster_entity'; +import { k8sCronJobEntity } from './kubernetes/cron_job_entity'; +import { k8sDaemonSetEntity } from './kubernetes/daemon_set_entity'; +import { k8sDeploymentEntity } from './kubernetes/deployment_entity'; +import { k8sJobSetEntity } from './kubernetes/job_set_entity'; +import { k8sNodeEntity } from './kubernetes/node_entity'; +import { k8sPodEntity } from './kubernetes/pod_entity'; +import { k8sReplicaSetEntity } from './kubernetes/replica_set'; +import { k8sStatefulSetEntity } from './kubernetes/stateful_set'; +import { k8sContainerEntity } from './kubernetes/container_entity'; export type EntityDataStreamType = 'metrics' | 'logs' | 'traces'; +export type Schema = 'ecs' | 'semconv'; export type EntityFields = Fields & Partial<{ @@ -32,4 +43,20 @@ export type EntityFields = Fields & [key: string]: any; }>; -export const entities = { serviceEntity, hostEntity, containerEntity }; +export const entities = { + serviceEntity, + hostEntity, + containerEntity, + k8s: { + k8sClusterJobEntity, + k8sCronJobEntity, + k8sDaemonSetEntity, + k8sDeploymentEntity, + k8sJobSetEntity, + k8sNodeEntity, + k8sPodEntity, + k8sReplicaSetEntity, + k8sStatefulSetEntity, + k8sContainerEntity, + }, +}; diff --git a/packages/kbn-apm-synthtrace-client/src/lib/entities/kubernetes/cluster_entity.ts b/packages/kbn-apm-synthtrace-client/src/lib/entities/kubernetes/cluster_entity.ts new file mode 100644 index 0000000000000..9fa4c81d86ffb --- /dev/null +++ b/packages/kbn-apm-synthtrace-client/src/lib/entities/kubernetes/cluster_entity.ts @@ -0,0 +1,39 @@ +/* + * 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", the "GNU Affero General Public License v3.0 only", and the "Server Side + * Public License v 1"; you may not use this file except in compliance with, at + * your election, the "Elastic License 2.0", the "GNU Affero General Public + * License v3.0 only", or the "Server Side Public License, v 1". + */ + +import { Schema } from '..'; +import { K8sEntity } from '.'; + +export function k8sClusterJobEntity({ + schema, + name, + entityId, + ...others +}: { + schema: Schema; + name: string; + entityId: string; + [key: string]: any; +}) { + if (schema === 'ecs') { + return new K8sEntity(schema, { + 'entity.type': 'cluster', + 'orchestrator.cluster.name': name, + 'entity.id': entityId, + ...others, + }); + } + + return new K8sEntity(schema, { + 'entity.type': 'cluster', + 'k8s.cluster.uid': name, + 'entity.id': entityId, + ...others, + }); +} diff --git a/packages/kbn-apm-synthtrace-client/src/lib/entities/kubernetes/container_entity.ts b/packages/kbn-apm-synthtrace-client/src/lib/entities/kubernetes/container_entity.ts new file mode 100644 index 0000000000000..b05d412b0dd5c --- /dev/null +++ b/packages/kbn-apm-synthtrace-client/src/lib/entities/kubernetes/container_entity.ts @@ -0,0 +1,39 @@ +/* + * 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", the "GNU Affero General Public License v3.0 only", and the "Server Side + * Public License v 1"; you may not use this file except in compliance with, at + * your election, the "Elastic License 2.0", the "GNU Affero General Public + * License v3.0 only", or the "Server Side Public License, v 1". + */ + +import { Schema } from '..'; +import { K8sEntity } from '.'; + +export function k8sContainerEntity({ + schema, + id, + entityId, + ...others +}: { + schema: Schema; + id: string; + entityId: string; + [key: string]: any; +}) { + if (schema === 'ecs') { + return new K8sEntity(schema, { + 'entity.type': 'container', + 'kubernetes.container.id': id, + 'entity.id': entityId, + ...others, + }); + } + + return new K8sEntity(schema, { + 'entity.type': 'container', + 'container.id': id, + 'entity.id': entityId, + ...others, + }); +} diff --git a/packages/kbn-apm-synthtrace-client/src/lib/entities/kubernetes/cron_job_entity.ts b/packages/kbn-apm-synthtrace-client/src/lib/entities/kubernetes/cron_job_entity.ts new file mode 100644 index 0000000000000..8590378e699fb --- /dev/null +++ b/packages/kbn-apm-synthtrace-client/src/lib/entities/kubernetes/cron_job_entity.ts @@ -0,0 +1,47 @@ +/* + * 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", the "GNU Affero General Public License v3.0 only", and the "Server Side + * Public License v 1"; you may not use this file except in compliance with, at + * your election, the "Elastic License 2.0", the "GNU Affero General Public + * License v3.0 only", or the "Server Side Public License, v 1". + */ + +import { Schema } from '..'; +import { K8sEntity } from '.'; + +export function k8sCronJobEntity({ + schema, + name, + uid, + clusterName, + entityId, + ...others +}: { + schema: Schema; + name: string; + uid?: string; + clusterName?: string; + entityId: string; + [key: string]: any; +}) { + if (schema === 'ecs') { + return new K8sEntity(schema, { + 'entity.type': 'cron_job', + 'kubernetes.cronjob.name': name, + 'kubernetes.cronjob.uid': uid, + 'kubernetes.namespace': clusterName, + 'entity.id': entityId, + ...others, + }); + } + + return new K8sEntity(schema, { + 'entity.type': 'cron_job', + 'k8s.cronjob.name': name, + 'k8s.cronjob.uid': uid, + 'k8s.cluster.name': clusterName, + 'entity.id': entityId, + ...others, + }); +} diff --git a/packages/kbn-apm-synthtrace-client/src/lib/entities/kubernetes/daemon_set_entity.ts b/packages/kbn-apm-synthtrace-client/src/lib/entities/kubernetes/daemon_set_entity.ts new file mode 100644 index 0000000000000..7e20b1c6d506f --- /dev/null +++ b/packages/kbn-apm-synthtrace-client/src/lib/entities/kubernetes/daemon_set_entity.ts @@ -0,0 +1,47 @@ +/* + * 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", the "GNU Affero General Public License v3.0 only", and the "Server Side + * Public License v 1"; you may not use this file except in compliance with, at + * your election, the "Elastic License 2.0", the "GNU Affero General Public + * License v3.0 only", or the "Server Side Public License, v 1". + */ + +import { Schema } from '..'; +import { K8sEntity } from '.'; + +export function k8sDaemonSetEntity({ + schema, + name, + uid, + clusterName, + entityId, + ...others +}: { + schema: Schema; + name: string; + uid?: string; + clusterName?: string; + entityId: string; + [key: string]: any; +}) { + if (schema === 'ecs') { + return new K8sEntity(schema, { + 'entity.type': 'daemon_set', + 'kubernetes.daemonset.name': name, + 'kubernetes.daemonset.uid': uid, + 'kubernetes.namespace': clusterName, + 'entity.id': entityId, + ...others, + }); + } + + return new K8sEntity(schema, { + 'entity.type': 'daemon_set', + 'k8s.daemonset.name': name, + 'k8s.daemonset.uid': uid, + 'k8s.cluster.name': clusterName, + 'entity.id': entityId, + ...others, + }); +} diff --git a/packages/kbn-apm-synthtrace-client/src/lib/entities/kubernetes/deployment_entity.ts b/packages/kbn-apm-synthtrace-client/src/lib/entities/kubernetes/deployment_entity.ts new file mode 100644 index 0000000000000..7eabdd0827325 --- /dev/null +++ b/packages/kbn-apm-synthtrace-client/src/lib/entities/kubernetes/deployment_entity.ts @@ -0,0 +1,47 @@ +/* + * 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", the "GNU Affero General Public License v3.0 only", and the "Server Side + * Public License v 1"; you may not use this file except in compliance with, at + * your election, the "Elastic License 2.0", the "GNU Affero General Public + * License v3.0 only", or the "Server Side Public License, v 1". + */ + +import { Schema } from '..'; +import { K8sEntity } from '.'; + +export function k8sDeploymentEntity({ + schema, + name, + uid, + clusterName, + entityId, + ...others +}: { + schema: Schema; + name: string; + uid?: string; + clusterName?: string; + entityId: string; + [key: string]: any; +}) { + if (schema === 'ecs') { + return new K8sEntity(schema, { + 'entity.type': 'deployment', + 'kubernetes.deployment.name': name, + 'kubernetes.deployment.uid': uid, + 'kubernetes.namespace': clusterName, + 'entity.id': entityId, + ...others, + }); + } + + return new K8sEntity(schema, { + 'entity.type': 'deployment', + 'k8s.deployment.name': name, + 'k8s.deployment.uid': uid, + 'k8s.cluster.name': clusterName, + 'entity.id': entityId, + ...others, + }); +} diff --git a/packages/kbn-apm-synthtrace-client/src/lib/entities/kubernetes/index.ts b/packages/kbn-apm-synthtrace-client/src/lib/entities/kubernetes/index.ts new file mode 100644 index 0000000000000..36d7f8caf9601 --- /dev/null +++ b/packages/kbn-apm-synthtrace-client/src/lib/entities/kubernetes/index.ts @@ -0,0 +1,76 @@ +/* + * 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", the "GNU Affero General Public License v3.0 only", and the "Server Side + * Public License v 1"; you may not use this file except in compliance with, at + * your election, the "Elastic License 2.0", the "GNU Affero General Public + * License v3.0 only", or the "Server Side Public License, v 1". + */ + +import type { EntityFields, Schema } from '..'; +import { Serializable } from '../../serializable'; + +const identityFieldsMap: Record> = { + ecs: { + pod: ['kubernetes.pod.name'], + cluster: ['orchestrator.cluster.name'], + cron_job: ['kubernetes.cronjob.name'], + daemon_set: ['kubernetes.daemonset.name'], + deployment: ['kubernetes.deployment.name'], + job: ['kubernetes.job.name'], + node: ['kubernetes.node.name'], + replica_set: ['kubernetes.replicaset.name'], + stateful_set: ['kubernetes.statefulset.name'], + container: ['kubernetes.container.id'], + }, + semconv: { + pod: ['k8s.pod.name'], + cluster: ['k8s.cluster.uid'], + cron_job: ['k8s.cronjob.name'], + daemon_set: ['k8s.daemonset.name'], + deployment: ['k8s.deployment.name'], + job: ['k8s.job.name'], + node: ['k8s.node.uid'], + replica_set: ['k8s.replicaset.name'], + stateful_set: ['k8s.statefulset.name'], + container: ['container.id'], + }, +}; + +export class K8sEntity extends Serializable { + constructor(schema: Schema, fields: EntityFields) { + const entityType = fields['entity.type']; + if (entityType === undefined) { + throw new Error(`Entity type not defined: ${entityType}`); + } + + const entityTypeWithSchema = `kubernetes_${entityType}_${schema}`; + const identityFields = identityFieldsMap[schema][entityType]; + if (identityFields === undefined || identityFields.length === 0) { + throw new Error( + `Identity fields not defined for schema: ${schema} and entity type: ${entityType}` + ); + } + + super({ + ...fields, + 'entity.type': entityTypeWithSchema, + 'entity.definitionId': `builtin_${entityTypeWithSchema}`, + 'entity.identityFields': identityFields, + 'entity.displayName': getDisplayName({ identityFields, fields }), + }); + } +} + +function getDisplayName({ + identityFields, + fields, +}: { + identityFields: string[]; + fields: EntityFields; +}) { + return identityFields + .map((field) => fields[field]) + .filter((_) => _) + .join(':'); +} diff --git a/packages/kbn-apm-synthtrace-client/src/lib/entities/kubernetes/job_set_entity.ts b/packages/kbn-apm-synthtrace-client/src/lib/entities/kubernetes/job_set_entity.ts new file mode 100644 index 0000000000000..e0383563c7266 --- /dev/null +++ b/packages/kbn-apm-synthtrace-client/src/lib/entities/kubernetes/job_set_entity.ts @@ -0,0 +1,47 @@ +/* + * 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", the "GNU Affero General Public License v3.0 only", and the "Server Side + * Public License v 1"; you may not use this file except in compliance with, at + * your election, the "Elastic License 2.0", the "GNU Affero General Public + * License v3.0 only", or the "Server Side Public License, v 1". + */ + +import { Schema } from '..'; +import { K8sEntity } from '.'; + +export function k8sJobSetEntity({ + schema, + name, + uid, + clusterName, + entityId, + ...others +}: { + schema: Schema; + name: string; + uid?: string; + clusterName?: string; + entityId: string; + [key: string]: any; +}) { + if (schema === 'ecs') { + return new K8sEntity(schema, { + 'entity.type': 'job', + 'kubernetes.job.name': name, + 'kubernetes.job.uid': uid, + 'kubernetes.namespace': clusterName, + 'entity.id': entityId, + ...others, + }); + } + + return new K8sEntity(schema, { + 'entity.type': 'job', + 'k8s.job.name': name, + 'k8s.job.uid': uid, + 'k8s.cluster.name': clusterName, + 'entity.id': entityId, + ...others, + }); +} diff --git a/packages/kbn-apm-synthtrace-client/src/lib/entities/kubernetes/node_entity.ts b/packages/kbn-apm-synthtrace-client/src/lib/entities/kubernetes/node_entity.ts new file mode 100644 index 0000000000000..283df5250d41d --- /dev/null +++ b/packages/kbn-apm-synthtrace-client/src/lib/entities/kubernetes/node_entity.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", the "GNU Affero General Public License v3.0 only", and the "Server Side + * Public License v 1"; you may not use this file except in compliance with, at + * your election, the "Elastic License 2.0", the "GNU Affero General Public + * License v3.0 only", or the "Server Side Public License, v 1". + */ + +import { Schema } from '..'; +import { K8sEntity } from '.'; + +export function k8sNodeEntity({ + schema, + name, + uid, + clusterName, + entityId, + ...others +}: { + schema: Schema; + name: string; + uid?: string; + clusterName?: string; + entityId: string; + [key: string]: any; +}) { + if (schema === 'ecs') { + return new K8sEntity(schema, { + 'entity.type': 'node', + 'kubernetes.node.name': name, + 'kubernetes.node.uid': uid, + 'kubernetes.namespace': clusterName, + 'entity.id': entityId, + ...others, + }); + } + + return new K8sEntity(schema, { + 'entity.type': 'node', + 'k8s.node.uid': uid, + 'k8s.cluster.name': clusterName, + 'entity.id': entityId, + ...others, + }); +} diff --git a/packages/kbn-apm-synthtrace-client/src/lib/entities/kubernetes/pod_entity.ts b/packages/kbn-apm-synthtrace-client/src/lib/entities/kubernetes/pod_entity.ts new file mode 100644 index 0000000000000..1b71c4e39a4fc --- /dev/null +++ b/packages/kbn-apm-synthtrace-client/src/lib/entities/kubernetes/pod_entity.ts @@ -0,0 +1,47 @@ +/* + * 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", the "GNU Affero General Public License v3.0 only", and the "Server Side + * Public License v 1"; you may not use this file except in compliance with, at + * your election, the "Elastic License 2.0", the "GNU Affero General Public + * License v3.0 only", or the "Server Side Public License, v 1". + */ + +import { Schema } from '..'; +import { K8sEntity } from '.'; + +export function k8sPodEntity({ + schema, + name, + uid, + clusterName, + entityId, + ...others +}: { + schema: Schema; + name: string; + uid?: string; + clusterName?: string; + entityId: string; + [key: string]: any; +}) { + if (schema === 'ecs') { + return new K8sEntity(schema, { + 'entity.type': 'pod', + 'kubernetes.pod.name': name, + 'kubernetes.pod.uid': uid, + 'kubernetes.namespace': clusterName, + 'entity.id': entityId, + ...others, + }); + } + + return new K8sEntity(schema, { + 'entity.type': 'pod', + 'k8s.pod.name': name, + 'k8s.pod.uid': uid, + 'k8s.cluster.name': clusterName, + 'entity.id': entityId, + ...others, + }); +} diff --git a/packages/kbn-apm-synthtrace-client/src/lib/entities/kubernetes/replica_set.ts b/packages/kbn-apm-synthtrace-client/src/lib/entities/kubernetes/replica_set.ts new file mode 100644 index 0000000000000..fcf20c0530c30 --- /dev/null +++ b/packages/kbn-apm-synthtrace-client/src/lib/entities/kubernetes/replica_set.ts @@ -0,0 +1,47 @@ +/* + * 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", the "GNU Affero General Public License v3.0 only", and the "Server Side + * Public License v 1"; you may not use this file except in compliance with, at + * your election, the "Elastic License 2.0", the "GNU Affero General Public + * License v3.0 only", or the "Server Side Public License, v 1". + */ + +import { Schema } from '..'; +import { K8sEntity } from '.'; + +export function k8sReplicaSetEntity({ + schema, + name, + uid, + clusterName, + entityId, + ...others +}: { + schema: Schema; + name: string; + uid?: string; + clusterName?: string; + entityId: string; + [key: string]: any; +}) { + if (schema === 'ecs') { + return new K8sEntity(schema, { + 'entity.type': 'replica_set', + 'kubernetes.replicaset.name': name, + 'kubernetes.replicaset.uid': uid, + 'kubernetes.namespace': clusterName, + 'entity.id': entityId, + ...others, + }); + } + + return new K8sEntity(schema, { + 'entity.type': 'replica_set', + 'k8s.replicaset.name': name, + 'k8s.replicaset.uid': uid, + 'k8s.cluster.name': clusterName, + 'entity.id': entityId, + ...others, + }); +} diff --git a/packages/kbn-apm-synthtrace-client/src/lib/entities/kubernetes/stateful_set.ts b/packages/kbn-apm-synthtrace-client/src/lib/entities/kubernetes/stateful_set.ts new file mode 100644 index 0000000000000..58c603704ebc0 --- /dev/null +++ b/packages/kbn-apm-synthtrace-client/src/lib/entities/kubernetes/stateful_set.ts @@ -0,0 +1,47 @@ +/* + * 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", the "GNU Affero General Public License v3.0 only", and the "Server Side + * Public License v 1"; you may not use this file except in compliance with, at + * your election, the "Elastic License 2.0", the "GNU Affero General Public + * License v3.0 only", or the "Server Side Public License, v 1". + */ + +import { Schema } from '..'; +import { K8sEntity } from '.'; + +export function k8sStatefulSetEntity({ + schema, + name, + uid, + clusterName, + entityId, + ...others +}: { + schema: Schema; + name: string; + uid?: string; + clusterName?: string; + entityId: string; + [key: string]: any; +}) { + if (schema === 'ecs') { + return new K8sEntity(schema, { + 'entity.type': 'stateful_set', + 'kubernetes.statefulset.name': name, + 'kubernetes.statefulset.uid': uid, + 'kubernetes.namespace': clusterName, + 'entity.id': entityId, + ...others, + }); + } + + return new K8sEntity(schema, { + 'entity.type': 'stateful_set', + 'k8s.statefulset.name': name, + 'k8s.statefulset.uid': uid, + 'k8s.cluster.name': clusterName, + 'entity.id': entityId, + ...others, + }); +} diff --git a/packages/kbn-apm-synthtrace/src/lib/entities/entities_synthtrace_es_client.ts b/packages/kbn-apm-synthtrace/src/lib/entities/entities_synthtrace_es_client.ts index 684e3efc0f372..65bf290eae32f 100644 --- a/packages/kbn-apm-synthtrace/src/lib/entities/entities_synthtrace_es_client.ts +++ b/packages/kbn-apm-synthtrace/src/lib/entities/entities_synthtrace_es_client.ts @@ -82,7 +82,8 @@ function getRoutingTransform() { const entityIndexName = `${entityType}s`; document._action = { index: { - _index: `.entities.v1.latest.builtin_${entityIndexName}_from_ecs_data`, + _index: + `.entities.v1.latest.builtin_${entityIndexName}_from_ecs_data`.toLocaleLowerCase(), _id: document['entity.id'], }, }; diff --git a/packages/kbn-apm-synthtrace/src/scenarios/k8s_entities.ts b/packages/kbn-apm-synthtrace/src/scenarios/k8s_entities.ts new file mode 100644 index 0000000000000..7d94cc3180a7e --- /dev/null +++ b/packages/kbn-apm-synthtrace/src/scenarios/k8s_entities.ts @@ -0,0 +1,155 @@ +/* + * 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", the "GNU Affero General Public License v3.0 only", and the "Server Side + * Public License v 1"; you may not use this file except in compliance with, at + * your election, the "Elastic License 2.0", the "GNU Affero General Public + * License v3.0 only", or the "Server Side Public License, v 1". + */ + +import { EntityFields, entities, generateShortId } from '@kbn/apm-synthtrace-client'; +import { Schema } from '@kbn/apm-synthtrace-client/src/lib/entities'; +import { Scenario } from '../cli/scenario'; +import { withClient } from '../lib/utils/with_client'; + +const CLUSTER_NAME = 'cluster_foo'; + +const CLUSTER_ENTITY_ID = generateShortId(); +const POD_ENTITY_ID = generateShortId(); +const POD_UID = generateShortId(); +const REPLICA_SET_ENTITY_ID = generateShortId(); +const REPLICA_SET_UID = generateShortId(); +const DEPLOYMENT_ENTITY_ID = generateShortId(); +const DEPLOYMENT_UID = generateShortId(); +const STATEFUL_SET_ENTITY_ID = generateShortId(); +const STATEFUL_SET_UID = generateShortId(); +const DAEMON_SET_ENTITY_ID = generateShortId(); +const DAEMON_SET_UID = generateShortId(); +const JOB_SET_ENTITY_ID = generateShortId(); +const JOB_SET_UID = generateShortId(); +const CRON_JOB_ENTITY_ID = generateShortId(); +const CRON_JOB_UID = generateShortId(); +const NODE_ENTITY_ID = generateShortId(); +const NODE_UID = generateShortId(); + +const scenario: Scenario> = async (runOptions) => { + const { logger } = runOptions; + + return { + bootstrap: async ({ entitiesKibanaClient }) => { + await entitiesKibanaClient.installEntityIndexPatterns(); + }, + generate: ({ range, clients: { entitiesEsClient } }) => { + const getK8sEntitiesEvents = (schema: Schema) => + range + .interval('1m') + .rate(1) + .generator((timestamp) => { + return [ + entities.k8s + .k8sClusterJobEntity({ + schema, + name: CLUSTER_NAME, + entityId: CLUSTER_ENTITY_ID, + }) + .timestamp(timestamp), + entities.k8s + .k8sPodEntity({ + schema, + clusterName: CLUSTER_NAME, + name: 'pod_foo', + uid: POD_UID, + entityId: POD_ENTITY_ID, + }) + .timestamp(timestamp), + entities.k8s + .k8sReplicaSetEntity({ + clusterName: CLUSTER_NAME, + name: 'replica_set_foo', + schema, + uid: REPLICA_SET_UID, + entityId: REPLICA_SET_ENTITY_ID, + }) + .timestamp(timestamp), + entities.k8s + .k8sDeploymentEntity({ + clusterName: CLUSTER_NAME, + name: 'deployment_foo', + schema, + uid: DEPLOYMENT_UID, + entityId: DEPLOYMENT_ENTITY_ID, + }) + .timestamp(timestamp), + entities.k8s + .k8sStatefulSetEntity({ + clusterName: CLUSTER_NAME, + name: 'stateful_set_foo', + schema, + uid: STATEFUL_SET_UID, + entityId: STATEFUL_SET_ENTITY_ID, + }) + .timestamp(timestamp), + entities.k8s + .k8sDaemonSetEntity({ + clusterName: CLUSTER_NAME, + name: 'daemon_set_foo', + schema, + uid: DAEMON_SET_UID, + entityId: DAEMON_SET_ENTITY_ID, + }) + .timestamp(timestamp), + entities.k8s + .k8sJobSetEntity({ + clusterName: CLUSTER_NAME, + name: 'job_set_foo', + schema, + uid: JOB_SET_UID, + entityId: JOB_SET_ENTITY_ID, + }) + .timestamp(timestamp), + entities.k8s + .k8sCronJobEntity({ + clusterName: CLUSTER_NAME, + name: 'cron_job_foo', + schema, + uid: CRON_JOB_UID, + entityId: CRON_JOB_ENTITY_ID, + }) + .timestamp(timestamp), + entities.k8s + .k8sNodeEntity({ + clusterName: CLUSTER_NAME, + name: 'node_job_foo', + schema, + uid: NODE_UID, + entityId: NODE_ENTITY_ID, + }) + .timestamp(timestamp), + entities.k8s + .k8sContainerEntity({ + id: '123', + schema, + entityId: NODE_ENTITY_ID, + }) + .timestamp(timestamp), + ]; + }); + + const ecsEntities = getK8sEntitiesEvents('ecs'); + const otelEntities = getK8sEntitiesEvents('semconv'); + + return [ + withClient( + entitiesEsClient, + logger.perf('generating_entities_ecs_events', () => ecsEntities) + ), + withClient( + entitiesEsClient, + logger.perf('generating_entities_otel_events', () => otelEntities) + ), + ]; + }, + }; +}; + +export default scenario;