From 250c2dd0d02f3ab89156e2acdb22afe942a9aa97 Mon Sep 17 00:00:00 2001 From: Ray Qiu Date: Fri, 29 Mar 2019 22:37:40 -0500 Subject: [PATCH] Cherry-pick #11549 to 7.0: Fix issue 11543 when key 'log' does not exist (#11553) * Fix panic in add_kubernetes_metadata processor when key `log` does not exist. {issue}11543[11543] (cherry picked from commit aba44a8273b2cd87440a662942fcc08642ece392) --- CHANGELOG.next.asciidoc | 1 + filebeat/processor/add_kubernetes_metadata/matchers.go | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.next.asciidoc b/CHANGELOG.next.asciidoc index 1384fc584345..b67330519cb3 100644 --- a/CHANGELOG.next.asciidoc +++ b/CHANGELOG.next.asciidoc @@ -42,6 +42,7 @@ https://github.com/elastic/beats/compare/v7.0.0-rc1...master[Check the HEAD diff *Filebeat* - Don't apply multiline rules in Logstash json logs. {pull}11346[11346] +- Fix panic in add_kubernetes_metadata processor when key `log` does not exist. {issue}11543[11543] {pull}11549[11549] *Heartbeat* diff --git a/filebeat/processor/add_kubernetes_metadata/matchers.go b/filebeat/processor/add_kubernetes_metadata/matchers.go index c984c0f60e6e..b95ea7101f6f 100644 --- a/filebeat/processor/add_kubernetes_metadata/matchers.go +++ b/filebeat/processor/add_kubernetes_metadata/matchers.go @@ -77,7 +77,8 @@ const containerIdLen = 64 const podUIDPos = 5 func (f *LogPathMatcher) MetadataIndex(event common.MapStr) string { - if value, ok := event["log"].(common.MapStr)["file"].(common.MapStr)["path"]; ok { + value, err := event.GetValue("log.file.path") + if err == nil { source := value.(string) logp.Debug("kubernetes", "Incoming log.file.path value: %s", source)