telegraf: Goroutine panic in docker.parseContainerStats

I’m getting a panic when running Telegraf v1.15 and v1.17:

Stacktrace

2021-01-14T13:03:28Z I! Starting Telegraf 1.17.0
2021-01-14T13:03:28Z I! Using config file: /etc/telegraf/telegraf.conf
2021-01-14T13:03:28Z I! Loaded inputs: cpu disk diskio docker kernel mem processes swap system
2021-01-14T13:03:28Z I! Loaded aggregators: 
2021-01-14T13:03:28Z I! Loaded processors: 
2021-01-14T13:03:28Z I! Loaded outputs: influxdb
2021-01-14T13:03:28Z I! Tags enabled: host=xxx
2021-01-14T13:03:28Z I! [agent] Config: Interval:10s, Quiet:false, Hostname:"xxx", Flush Interval:10s
panic: runtime error: slice bounds out of range [:12] with capacity 0

goroutine 163 [running]:
github.com/influxdata/telegraf/plugins/inputs/docker.parseContainerStats(0xc000592480, 0x348a6c0, 0xc0002643a0, 0xc00037d860, 0xc000c0a2c0, 0x40, 0x1, 0xc0006d4936, 0x5)
	/go/src/github.com/influxdata/telegraf/plugins/inputs/docker/docker.go:677 +0x23e5
github.com/influxdata/telegraf/plugins/inputs/docker.(*Docker).gatherContainerInspect(0xc0005bc600, 0xc000c0a2c0, 0x40, 0xc0000c9fc0, 0x1, 0x4, 0xc000afb660, 0xd, 0xc000c08190, 0x47, ...)
	/go/src/github.com/influxdata/telegraf/plugins/inputs/docker/docker.go:568 +0x20e
github.com/influxdata/telegraf/plugins/inputs/docker.(*Docker).gatherContainer(0xc0005bc600, 0xc000c0a2c0, 0x40, 0xc0000c9fc0, 0x1, 0x4, 0xc000afb660, 0xd, 0xc000c08190, 0x47, ...)
	/go/src/github.com/influxdata/telegraf/plugins/inputs/docker/docker.go:495 +0x910
github.com/influxdata/telegraf/plugins/inputs/docker.(*Docker).Gather.func1(0xc000afbb80, 0xc0005bc600, 0x348a6c0, 0xc0002643a0, 0xc000c0a2c0, 0x40, 0xc0000c9fc0, 0x1, 0x4, 0xc000afb660, ...)
	/go/src/github.com/influxdata/telegraf/plugins/inputs/docker/docker.go:217 +0xbd
created by github.com/influxdata/telegraf/plugins/inputs/docker.(*Docker).Gather
	/go/src/github.com/influxdata/telegraf/plugins/inputs/docker/docker.go:215 +0x3f8

Relevant source code: https://github.com/influxdata/telegraf/blob/fbd54e84a2c5b4355b92a4ade0fd50805a5bff7e/plugins/inputs/docker/docker.go#L673-L680

It seems that a double check of the data actually being present would be useful, even though it might hide other problems. Perhaps a warning is in order.

Environment

Linux

OS: Debian unstable.

Linux akili 5.10.0-1-amd64 #1 SMP Debian 5.10.4-1 (2020-12-31) x86_64 GNU/Linux

Docker

Client:
 Version:           20.10.0+dfsg2
 API version:       1.41
 Go version:        go1.15.6
 Git commit:        7287ab3
 Built:             Mon Dec 14 12:39:22 2020
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server:
 Engine:
  Version:          20.10.0+dfsg2
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.15.6
  Git commit:       eeddea2
  Built:            Mon Dec 14 12:39:22 2020
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.4.3~ds1
  GitCommit:        1.4.3~ds1-1
 runc:
  Version:          1.0.0~rc92+dfsg1
  GitCommit:        1.0.0~rc92+dfsg1-5
 docker-init:
  Version:          0.19.0
  GitCommit:        

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 1
  • Comments: 44 (14 by maintainers)

Most upvoted comments