From 42507e14d03b8584d66eba3dd681d1d1831da923 Mon Sep 17 00:00:00 2001 From: Jaime Soriano Pastor Date: Wed, 21 Nov 2018 20:13:01 +0100 Subject: [PATCH] Fix panic on docker healthcheck collection (#9171) (#9180) Fix panic on docker healthcheck collection on dockers without healthchecks. (cherry picked from commit 1c43d6cb4c549f3f566bec2c89f51ebd126f82b2) --- CHANGELOG.asciidoc | 1 + metricbeat/module/docker/healthcheck/data.go | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index fec653c930f..e58e118355c 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -55,6 +55,7 @@ https://github.com/elastic/beats/compare/v6.5.0...6.x[Check the HEAD diff] *Metricbeat* - Fix race condition when enriching events with kubernetes metadata. {issue}9055[9055] {issue}9067[9067] +- Fix panic on docker healthcheck collection on dockers without healthchecks. {pull}9171[9171] *Packetbeat* diff --git a/metricbeat/module/docker/healthcheck/data.go b/metricbeat/module/docker/healthcheck/data.go index 0b745827600..dc91093c918 100644 --- a/metricbeat/module/docker/healthcheck/data.go +++ b/metricbeat/module/docker/healthcheck/data.go @@ -50,6 +50,12 @@ func eventMapping(cont *types.Container, m *MetricSet) common.MapStr { logp.Err("Error inspecting container %v: %v", cont.ID, err) return nil } + + // Check if the container has any health check + if container.State.Health == nil { + return nil + } + lastEvent := len(container.State.Health.Log) - 1 // Checks if a healthcheck already happened