forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[EEM] Add built in definitions for hosts and containers (elastic#193157)
### Summary This PR adds built in definitions for `hosts` and `containers` based on ECS data. ### How to test 1. Check out this branch of Kibana 2. Start ES and Kibana, verify that start up works and that the two definitions are installed (by calling `GET /internal/entities/definition` or checking that the transforms are installed). 3. Ingest some data for each definition to work with, verify that you get data in `entities-host-*` and `entities-container-*` and that the data matches the expected shape (metadata and metrics[1]) [[1]](elastic#193157 (comment))
- Loading branch information
1 parent
a65e904
commit 26a50f7
Showing
4 changed files
with
346 additions
and
3 deletions.
There are no files selected for viewing
158 changes: 158 additions & 0 deletions
158
x-pack/plugins/entity_manager/server/lib/entities/built_in/containers_from_ecs_data.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
/* | ||
* 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'; | ||
|
||
export const builtInContainersFromEcsEntityDefinition: EntityDefinition = | ||
entityDefinitionSchema.parse({ | ||
id: `${BUILT_IN_ID_PREFIX}containers_from_ecs_data`, | ||
managed: true, | ||
version: '1.0.0', | ||
name: 'Containers from ECS data', | ||
description: | ||
'This definition extracts container entities from common data streams by looking for the ECS field container.id', | ||
type: 'container', | ||
indexPatterns: ['filebeat-*', 'logs-*', 'metrics-*', 'metricbeat-*'], | ||
identityFields: ['container.id'], | ||
displayNameTemplate: '{{container.id}}', | ||
history: { | ||
timestampField: '@timestamp', | ||
interval: '5m', | ||
settings: { | ||
frequency: '5m', | ||
}, | ||
}, | ||
metadata: [ | ||
{ | ||
source: '_index', | ||
destination: 'source_index', | ||
}, | ||
{ | ||
source: 'data_stream.type', | ||
destination: 'source_data_stream.type', | ||
}, | ||
{ | ||
source: 'data_stream.dataset', | ||
destination: 'source_data_stream.dataset', | ||
}, | ||
'container.name', | ||
'container.image.name', | ||
'container.image.tag', | ||
'container.runtime', | ||
'host.name', | ||
'host.ip', | ||
'host.mac', | ||
'host.architecture', | ||
'host.os.family', | ||
'host.os.kernel', | ||
'host.os.name', | ||
'host.os.platform', | ||
'host.os.type', | ||
'host.os.version', | ||
'cloud.provider', | ||
'cloud.region', | ||
'cloud.availability_zone', | ||
'cloud.instance.id', | ||
'cloud.instance.name', | ||
'cloud.machine.type', | ||
'cloud.service.name', | ||
'agent.name', | ||
'agent.type', | ||
'agent.ephemeral_id', | ||
], | ||
metrics: [ | ||
{ | ||
name: 'log_rate', | ||
equation: 'A', | ||
metrics: [ | ||
{ | ||
name: 'A', | ||
aggregation: 'doc_count', | ||
filter: 'log.level: * OR error.log.level: *', | ||
}, | ||
], | ||
}, | ||
{ | ||
name: 'error_log_rate', | ||
equation: 'A', | ||
metrics: [ | ||
{ | ||
name: 'A', | ||
aggregation: 'doc_count', | ||
filter: '(log.level: "error" OR "ERROR") OR (error.log.level: "error" OR "ERROR")', | ||
}, | ||
], | ||
}, | ||
{ | ||
name: 'cpu_usage_avg', | ||
equation: 'A', | ||
metrics: [ | ||
{ | ||
name: 'A', | ||
aggregation: 'avg', | ||
field: 'docker.cpu.total.pct', | ||
}, | ||
], | ||
}, | ||
{ | ||
name: 'memory_usage_avg', | ||
equation: 'A', | ||
metrics: [ | ||
{ | ||
name: 'A', | ||
aggregation: 'avg', | ||
field: 'docker.memory.usage.pct', | ||
}, | ||
], | ||
}, | ||
{ | ||
name: 'network_in_avg', | ||
equation: 'A', | ||
metrics: [ | ||
{ | ||
name: 'A', | ||
aggregation: 'avg', | ||
field: 'docker.network.in.bytes', | ||
}, | ||
], | ||
}, | ||
{ | ||
name: 'network_out_avg', | ||
equation: 'A', | ||
metrics: [ | ||
{ | ||
name: 'A', | ||
aggregation: 'avg', | ||
field: 'docker.network.out.bytes', | ||
}, | ||
], | ||
}, | ||
{ | ||
name: 'disk_read_avg', | ||
equation: 'A', | ||
metrics: [ | ||
{ | ||
name: 'A', | ||
aggregation: 'avg', | ||
field: 'docker.diskio.read.ops', | ||
}, | ||
], | ||
}, | ||
{ | ||
name: 'disk_write_avg', | ||
equation: 'A', | ||
metrics: [ | ||
{ | ||
name: 'A', | ||
aggregation: 'avg', | ||
field: 'docker.diskio.write.ops', | ||
}, | ||
], | ||
}, | ||
], | ||
}); |
179 changes: 179 additions & 0 deletions
179
x-pack/plugins/entity_manager/server/lib/entities/built_in/hosts_from_ecs_data.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,179 @@ | ||
/* | ||
* 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'; | ||
|
||
export const builtInHostsFromEcsEntityDefinition: EntityDefinition = entityDefinitionSchema.parse({ | ||
id: `${BUILT_IN_ID_PREFIX}hosts_from_ecs_data`, | ||
managed: true, | ||
version: '1.0.0', | ||
name: 'Hosts from ECS data', | ||
description: | ||
'This definition extracts host entities from common data streams by looking for the ECS field host.name', | ||
type: 'host', | ||
indexPatterns: ['filebeat-*', 'logs-*', 'metrics-*', 'metricbeat-*'], | ||
identityFields: ['host.name'], | ||
displayNameTemplate: '{{host.name}}', | ||
history: { | ||
timestampField: '@timestamp', | ||
interval: '5m', | ||
settings: { | ||
frequency: '5m', | ||
}, | ||
}, | ||
metadata: [ | ||
{ | ||
source: '_index', | ||
destination: 'source_index', | ||
}, | ||
{ | ||
source: 'data_stream.type', | ||
destination: 'source_data_stream.type', | ||
}, | ||
{ | ||
source: 'data_stream.dataset', | ||
destination: 'source_data_stream.dataset', | ||
}, | ||
'host.hostname', | ||
'host.ip', | ||
'host.mac', | ||
'host.architecture', | ||
'host.containerized', | ||
'host.os.platform', | ||
'host.os.name', | ||
'host.os.type', | ||
'host.os.codename', | ||
'host.os.family', | ||
'host.os.kernel', | ||
'host.os.version', | ||
'cloud.provider', | ||
'cloud.region', | ||
'cloud.availability_zone', | ||
'cloud.instance.id', | ||
'cloud.instance.name', | ||
'cloud.service.name', | ||
'cloud.machine.type', | ||
'cloud.account.id', | ||
'cloud.project.id', | ||
'agent.id', | ||
'agent.name', | ||
'agent.type', | ||
'agent.version', | ||
], | ||
metrics: [ | ||
{ | ||
name: 'log_rate', | ||
equation: 'A', | ||
metrics: [ | ||
{ | ||
name: 'A', | ||
aggregation: 'doc_count', | ||
filter: 'log.level: * OR error.log.level: *', | ||
}, | ||
], | ||
}, | ||
{ | ||
name: 'error_log_rate', | ||
equation: 'A', | ||
metrics: [ | ||
{ | ||
name: 'A', | ||
aggregation: 'doc_count', | ||
filter: '(log.level: "error" OR "ERROR") OR (error.log.level: "error" OR "ERROR")', | ||
}, | ||
], | ||
}, | ||
{ | ||
name: 'cpu_usage_avg', | ||
equation: 'A', | ||
metrics: [ | ||
{ | ||
name: 'A', | ||
aggregation: 'avg', | ||
field: 'system.cpu.total.norm.pct', | ||
}, | ||
], | ||
}, | ||
{ | ||
name: 'normalized_load_avg', | ||
equation: 'A / B', | ||
metrics: [ | ||
{ | ||
name: 'A', | ||
aggregation: 'avg', | ||
field: 'system.load.1', | ||
}, | ||
{ | ||
name: 'B', | ||
aggregation: 'max', | ||
field: 'system.load.cores', | ||
}, | ||
], | ||
}, | ||
{ | ||
name: 'memory_usage_avg', | ||
equation: 'A', | ||
metrics: [ | ||
{ | ||
name: 'A', | ||
aggregation: 'avg', | ||
field: 'system.memory.actual.used.pct', | ||
}, | ||
], | ||
}, | ||
{ | ||
name: 'memory_free_avg', | ||
equation: 'A - B', | ||
metrics: [ | ||
{ | ||
name: 'A', | ||
aggregation: 'max', | ||
field: 'system.memory.total', | ||
}, | ||
{ | ||
name: 'B', | ||
aggregation: 'avg', | ||
field: 'system.memory.actual.used.bytes', | ||
}, | ||
], | ||
}, | ||
{ | ||
name: 'disk_usage_max', | ||
equation: 'A', | ||
metrics: [ | ||
{ | ||
name: 'A', | ||
aggregation: 'max', | ||
field: 'system.filesystem.used.pct', | ||
}, | ||
], | ||
}, | ||
{ | ||
name: 'rx_avg', | ||
equation: 'A * 8', | ||
metrics: [ | ||
{ | ||
name: 'A', | ||
aggregation: 'sum', | ||
field: 'host.network.ingress.bytes', | ||
}, | ||
], | ||
}, | ||
{ | ||
name: 'tx_avg', | ||
equation: 'A * 8', | ||
metrics: [ | ||
{ | ||
name: 'A', | ||
aggregation: 'sum', | ||
field: 'host.network.egress.bytes', | ||
}, | ||
], | ||
}, | ||
], | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters