Skip to content

Commit

Permalink
Fix panic in Redis key metricset (elastic#13426)
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 99ded55)
  • Loading branch information
jsoriano committed Aug 30, 2019
1 parent b4976bf commit 0a0f2c4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ https://github.com/elastic/beats/compare/v7.2.0...7.2[Check the HEAD diff]
*Metricbeat*

- Print errors that were being omitted in vSphere metricsets {pull}12816[12816]
- Fix panic in Redis Key metricset when collecting information from a removed key. {pull}13426[13426]

*Packetbeat*

Expand Down
7 changes: 6 additions & 1 deletion metricbeat/module/redis/key/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,14 @@ 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, p.Keyspace)
continue
}
event := eventMapping(p.Keyspace, keyInfo)
if !r.Event(event) {
return errors.New("metricset has closed")
m.Logger().Debug("Failed to report event, interrupting fetch")
return nil
}
}
}
Expand Down

0 comments on commit 0a0f2c4

Please sign in to comment.