Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Metricbeat] Add nil pointer checks for docker NetworkSettings #12628

Merged
merged 3 commits into from
Jun 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- Fix `@timestamp` being duplicated in events if `@timestamp` is set in a
processor (or by any code utilizing `PutValue()` on a `beat.Event`).
- Fix leak in script processor when using Javascript functions in a processor chain. {pull}12600[12600]
- Add additional nil pointer checks to Docker client code to deal with vSphere Integrated Containers {pull}12628[12628]

*Auditbeat*

Expand Down
9 changes: 6 additions & 3 deletions libbeat/common/docker/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,9 +334,12 @@ func (w *watcher) listContainers(options types.ContainerListOptions) ([]*Contain
var result []*Container
for _, c := range containers {
var ipaddresses []string
for _, net := range c.NetworkSettings.Networks {
if net.IPAddress != "" {
ipaddresses = append(ipaddresses, net.IPAddress)
if c.NetworkSettings != nil {
// Handle alternate platforms like VMWare's VIC that might not have this data.
for _, net := range c.NetworkSettings.Networks {
if net.IPAddress != "" {
ipaddresses = append(ipaddresses, net.IPAddress)
}
}
}

Expand Down
4 changes: 4 additions & 0 deletions metricbeat/module/docker/container/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ func eventMapping(r mb.ReporterV2, cont *types.Container, dedot bool) {
}

func extractIPAddresses(networks *types.SummaryNetworkSettings) []string {
// Handle alternate platforms like VMWare's VIC that might not have this data.
if networks == nil {
return []string{}
}
ipAddresses := make([]string, 0, len(networks.Networks))
for _, network := range networks.Networks {
if len(network.IPAddress) > 0 {
Expand Down