Skip to content

Commit

Permalink
Fix panic in Redis key metricset (elastic#13426) (elastic#13435)
Browse files Browse the repository at this point in the history
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 318a041)
  • Loading branch information
jsoriano committed Aug 30, 2019
1 parent d853e38 commit f8fefad
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Expand Up @@ -96,6 +96,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- Fix `logstash/node_stats` metricset to also collect `logstash_stats.events.duration_in_millis` field when `xpack.enabled: true` is set. {pull}13082[13082]
- Fix `logstash/node` metricset to also collect `logstash_state.pipeline.representation.{type,version,hash}` fields when `xpack.enabled: true` is set. {pull}13133[13133]
- Check if fields in DBInstance is nil in rds metricset. {pull}13294[13294] {issue}13037[13037]
- Fix panic in Redis Key metricset when collecting information from a removed key. {pull}13426[13426]

*Packetbeat*

Expand Down
4 changes: 4 additions & 0 deletions metricbeat/module/redis/key/key.go
Expand Up @@ -112,6 +112,10 @@ func (m *MetricSet) Fetch(r mb.ReporterV2) error {
r.Error(err)
continue
}
if keyInfo == nil {
m.Logger().Debugf("Ignoring removed key %s from keyspace %d", key, keyspace)
continue
}
event := eventMapping(keyspace, keyInfo)
if !r.Event(event) {
m.Logger().Debug("Failed to report event, interrupting fetch")
Expand Down

0 comments on commit f8fefad

Please sign in to comment.