Skip to content

Telegraf v1.22.1 panics when pulling metrics from Couchbase CE v5.0.1 #11017

@joelsdc

Description

@joelsdc

Relevant telegraf.conf

[[inputs.couchbase]]
    servers = ["http://user:pass@couchbase1.example.com:8091"]

Logs from Telegraf

2022-04-22T02:08:28Z I! Starting Telegraf 1.22.1
2022-04-22T02:08:28Z I! Loaded inputs: couchbase
2022-04-22T02:08:28Z I! Loaded aggregators:
2022-04-22T02:08:28Z I! Loaded processors:
2022-04-22T02:08:28Z W! Outputs are not used in testing mode!
2022-04-22T02:08:28Z I! Tags enabled: host=telegraf.example.com
2022-04-22T02:08:28Z D! [agent] Initializing plugins
2022-04-22T02:08:28Z D! [agent] Starting service inputs
> couchbase_node,cluster=http://couchbase1.example.com:8091,host=telegraf.example.com,hostname=couchbase1.example.com:8091 memory_free=18208051200,memory_total=50630598656 1650593308000000000
> couchbase_node,cluster=http://couchbase1.example.com:8091,host=telegraf.example.com,hostname=couchbase2.example.com:8091 memory_free=17832468480,memory_total=50630606848 1650593308000000000
> couchbase_node,cluster=http://couchbase1.example.com:8091,host=telegraf.example.com,hostname=couchbase3.example.com:8091 memory_free=18767409152,memory_total=50630606848 1650593308000000000
> couchbase_node,cluster=http://couchbase1.example.com:8091,host=telegraf.example.com,hostname=couchbase4.example.com:8091 memory_free=17904566272,memory_total=50630598656 1650593308000000000
> couchbase_node,cluster=http://couchbase1.example.com:8091,host=telegraf.example.com,hostname=couchbase5.example.com:8091 memory_free=17882521600,memory_total=50630606848 1650593308000000000
panic: runtime error: index out of range [-1]

goroutine 37 [running]:
github.com/influxdata/telegraf/plugins/inputs/couchbase.(*Couchbase).addBucketFieldChecked(0xc0000ce270, 0xc000b66e41, {0x53c7557, 0xc0004de660}, {0xc0004e8a00, 0x536144e, 0x915d723f9c9050fa}, 0xc000617b60)
    /go/src/github.com/influxdata/telegraf/plugins/inputs/couchbase/couchbase.go:373 +0xea
github.com/influxdata/telegraf/plugins/inputs/couchbase.(*Couchbase).gatherDetailedBucketStats(0x49a51e0, {0xc000b66e41, 0x3b}, {0xc0004de660, 0x6}, 0x0)
    /go/src/github.com/influxdata/telegraf/plugins/inputs/couchbase/couchbase.go:143 +0xee
github.com/influxdata/telegraf/plugins/inputs/couchbase.(*Couchbase).gatherServer(0xc0000ce270, {0x5edcb20, 0xc0004032a0}, {0xc000b66e41, 0x3b})
    /go/src/github.com/influxdata/telegraf/plugins/inputs/couchbase/couchbase.go:122 +0xc12
github.com/influxdata/telegraf/plugins/inputs/couchbase.(*Couchbase).Gather.func1({0xc000b66e41, 0x0})
    /go/src/github.com/influxdata/telegraf/plugins/inputs/couchbase/couchbase.go:75 +0x7f
created by github.com/influxdata/telegraf/plugins/inputs/couchbase.(*Couchbase).Gather
    /go/src/github.com/influxdata/telegraf/plugins/inputs/couchbase/couchbase.go:73 +0x1bd

System info

Telegraf 1.22.1, Debian 9.13

Docker

No response

Steps to reproduce

1. telegraf --config couchbase.conf --test --debug

Expected behavior

No panics!

Actual behavior

Telegraf panics

Additional info

Using: Couchbase CE 5.0.1 build 5003

NOTE: With Telegraf v1.16.3 and the same config we get the metrics with no panics:

2022-04-22T02:22:26Z I! Starting Telegraf 1.16.3
2022-04-22T02:22:26Z D! [agent] Initializing plugins
2022-04-22T02:22:26Z D! [agent] Starting service inputs
> couchbase_node,cluster=http://couchbase1.example.com:8091,host=telegraf.example.com,hostname=couchbase1.example.com:8091 memory_free=18184151040,memory_total=50630598656 1650594147000000000
> couchbase_node,cluster=http://couchbase1.example.com:8091,host=telegraf.example.com,hostname=couchbase2.example.com:8091 memory_free=17816256512,memory_total=50630606848 1650594147000000000
> couchbase_node,cluster=http://couchbase1.example.com:8091,host=telegraf.example.com,hostname=couchbase3.example.com:8091 memory_free=18760634368,memory_total=50630606848 1650594147000000000
> couchbase_node,cluster=http://couchbase1.example.com:8091,host=telegraf.example.com,hostname=couchbase4.example.com:8091 memory_free=17893912576,memory_total=50630598656 1650594147000000000
> couchbase_node,cluster=http://couchbase1.example.com:8091,host=telegraf.example.com,hostname=couchbase5.example.com:8091 memory_free=17863499776,memory_total=50630606848 1650594147000000000
> couchbase_bucket,bucket=cas_tgt,cluster=http://couchbase1.example.com:8091,host=telegraf.example.com data_used=184455980533,disk_fetches=0,disk_used=228852459951,item_count=33705518,mem_used=76277631736,ops_per_sec=8,quota_percent_used=78.93231152660317 1650594147000000000
> couchbase_bucket,bucket=cas_st,cluster=http://couchbase1.example.com:8091,host=telegraf.example.com item_count=24250,mem_used=790521566,ops_per_sec=136,quota_percent_used=1.227050966893633 1650594147000000000
2022-04-22T02:22:26Z D! [agent] Stopping service inputs
2022-04-22T02:22:26Z D! [agent] Input channel closed
2022-04-22T02:22:26Z D! [agent] Stopped Successfully

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/couchbasebugunexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions