From fd85b0d6fd85d9127a578344715e2bc29c428645 Mon Sep 17 00:00:00 2001 From: Jaime Soriano Pastor Date: Fri, 30 Aug 2019 12:45:23 +0200 Subject: [PATCH] Fix panic in Redis key metricset (#13426) If a key is removed during a fetch, `FetchKeyInfo` returns a nil object, this nil object should be ignored, if passed to `eventMapping` it panics. (cherry picked from commit 99ded55e9abcc8045f841a58904db6b5ca04c9ab) --- CHANGELOG.next.asciidoc | 2 ++ metricbeat/module/redis/key/key.go | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/CHANGELOG.next.asciidoc b/CHANGELOG.next.asciidoc index a7b4d2089688..baa4e33ad88b 100644 --- a/CHANGELOG.next.asciidoc +++ b/CHANGELOG.next.asciidoc @@ -46,6 +46,8 @@ https://github.com/elastic/beats/compare/v6.8.0...6.8.1[Check the HEAD diff] *Metricbeat* +- Fix panic in Redis Key metricset when collecting information from a removed key. {pull}13426[13426] + *Packetbeat* *Winlogbeat* diff --git a/metricbeat/module/redis/key/key.go b/metricbeat/module/redis/key/key.go index c60db25ad445..0118412a7014 100644 --- a/metricbeat/module/redis/key/key.go +++ b/metricbeat/module/redis/key/key.go @@ -95,6 +95,10 @@ func (m *MetricSet) Fetch(r mb.ReporterV2) { logp.Err("Failed to fetch key info for key %s in keyspace %d", key, p.Keyspace) continue } + if keyInfo == nil { + debugf("Ignoring removed key %s from keyspace %d", key, p.Keyspace) + continue + } event := eventMapping(p.Keyspace, keyInfo) if !r.Event(event) { debugf("Failed to report event, interrupting Fetch")