diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index 13c115ae98c..de4183173b1 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -102,6 +102,7 @@ https://github.com/elastic/beats/compare/v6.0.0-beta2...master[Check the HEAD di - Auto-select a hostname (based on the host on which the Beat is running) in the Host Overview dashboard. {pull}5340[5340] - Add Kubernetes manifests to deploy Metricbeat. {pull}5349[5349] - Add etcd module. {issue}4970[4970] +- Add ip address of docker containers to event. {pull}5379[5379] *Packetbeat* diff --git a/metricbeat/docs/fields.asciidoc b/metricbeat/docs/fields.asciidoc index 508310c3964..a4e3eab94c9 100644 --- a/metricbeat/docs/fields.asciidoc +++ b/metricbeat/docs/fields.asciidoc @@ -1908,6 +1908,14 @@ type: keyword Container status. +[float] +=== `docker.container.ip_addresses` + +type: keyword + +Container IP addresses. + + [float] == size fields diff --git a/metricbeat/module/docker/container/_meta/data.json b/metricbeat/module/docker/container/_meta/data.json index 5fec882399e..2a5e7b5feb5 100644 --- a/metricbeat/module/docker/container/_meta/data.json +++ b/metricbeat/module/docker/container/_meta/data.json @@ -18,6 +18,9 @@ "com_docker_compose_version": "1.9.0-rc4" }, "name": "environments_beat_run_1", + "ip_addresses": [ + "10.0.0.1" + ], "size": { "root_fs": 0, "rw": 0 diff --git a/metricbeat/module/docker/container/_meta/fields.yml b/metricbeat/module/docker/container/_meta/fields.yml index b22f2d6f30c..e0db89c38ae 100644 --- a/metricbeat/module/docker/container/_meta/fields.yml +++ b/metricbeat/module/docker/container/_meta/fields.yml @@ -15,6 +15,10 @@ type: keyword description: > Container status. + - name: ip_addresses + type: keyword + description: > + Container IP addresses. - name: size type: group description: > diff --git a/metricbeat/module/docker/container/data.go b/metricbeat/module/docker/container/data.go index 199cb4df2ae..492c7b39aee 100644 --- a/metricbeat/module/docker/container/data.go +++ b/metricbeat/module/docker/container/data.go @@ -19,11 +19,12 @@ func eventsMapping(containersList []dc.APIContainers) []common.MapStr { func eventMapping(cont *dc.APIContainers) common.MapStr { event := common.MapStr{ - "created": common.Time(time.Unix(cont.Created, 0)), - "id": cont.ID, - "name": docker.ExtractContainerName(cont.Names), - "command": cont.Command, - "image": cont.Image, + "created": common.Time(time.Unix(cont.Created, 0)), + "id": cont.ID, + "name": docker.ExtractContainerName(cont.Names), + "command": cont.Command, + "image": cont.Image, + "ip_addresses": extractIPAddresses(cont.Networks), "size": common.MapStr{ "root_fs": cont.SizeRootFs, "rw": cont.SizeRw, @@ -39,3 +40,11 @@ func eventMapping(cont *dc.APIContainers) common.MapStr { return event } + +func extractIPAddresses(networks dc.NetworkList) []string { + ipAddresses := make([]string, 0, len(networks.Networks)) + for _, network := range networks.Networks { + ipAddresses = append(ipAddresses, network.IPAddress) + } + return ipAddresses +}