mongodb_exporter icon indicating copy to clipboard operation
mongodb_exporter copied to clipboard

panic: runtime error: invalid memory address or nil pointer dereference

Open Bodenhaltung opened this issue 4 years ago • 6 comments

Hi,

on my vm the exporter crashed if i curl the metrics, i get a segfault:

./mongodb_exporter-linux-amd64 -mongodb.uri "mongodb://user:[email protected]:27017/database?replicaSet=rs0&authSource=admin"
Listening on :9001 (scheme=HTTP, secured=no, clientValidation=no)
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x508228]

goroutine 22 [running]:
panic(0x73d340, 0xc42000e090)
        /usr/local/go/src/runtime/panic.go:500 +0x1a1
github.com/dcu/mongodb_exporter/collector.(*PreloadStats).Export(0x0, 0xc420052240)
        /Users/dc/code/go/src/github.com/dcu/mongodb_exporter/collector/metrics.go:363 +0x38
github.com/dcu/mongodb_exporter/collector.(*ReplStats).Export(0xc42020ecc0, 0xc420052240)
        /Users/dc/code/go/src/github.com/dcu/mongodb_exporter/collector/metrics.go:352 +0x90
github.com/dcu/mongodb_exporter/collector.(*MetricsStats).Export(0xc42020bb80, 0xc420052240)
        /Users/dc/code/go/src/github.com/dcu/mongodb_exporter/collector/metrics.go:435 +0x4c7
github.com/dcu/mongodb_exporter/collector.(*ServerStatus).Export(0xc42008f9a0, 0xc420052240)
        /Users/dc/code/go/src/github.com/dcu/mongodb_exporter/collector/server_status.go:111 +0x1f9
github.com/dcu/mongodb_exporter/collector.(*MongodbCollector).collectServerStatus(0xc420048f50, 0xc4200f8680, 0xc420052240, 0x7235e0)
        /Users/dc/code/go/src/github.com/dcu/mongodb_exporter/collector/mongodb_collector.go:85 +0xe3
github.com/dcu/mongodb_exporter/collector.(*MongodbCollector).Collect(0xc420048f50, 0xc420052240)
        /Users/dc/code/go/src/github.com/dcu/mongodb_exporter/collector/mongodb_collector.go:64 +0x2d4
github.com/dcu/mongodb_exporter/vendor/github.com/prometheus/client_golang/prometheus.(*Registry).Gather.func2(0xc420054630, 0xc420052240, 0x928900, 0xc420048f50)
        /Users/dc/code/go/src/github.com/dcu/mongodb_exporter/vendor/github.com/prometheus/client_golang/prometheus/registry.go:433 +0x63
created by github.com/dcu/mongodb_exporter/vendor/github.com/prometheus/client_golang/prometheus.(*Registry).Gather
        /Users/dc/code/go/src/github.com/dcu/mongodb_exporter/vendor/github.com/prometheus/client_golang/prometheus/registry.go:434 +0x326

Bodenhaltung avatar Mar 03 '21 15:03 Bodenhaltung

@Bodenhaltung did you manage to work around this? I got the same problem.

tcurdt avatar Apr 06 '21 15:04 tcurdt

Facing same issue when I curl /metrics path @dcu can you fix the issue, Thanks in advance

saiakhil46 avatar Apr 09 '21 08:04 saiakhil46

I didn't find a work around and switched to https://github.com/percona/mongodb_exporter

tcurdt avatar Apr 09 '21 08:04 tcurdt

@tcurdt Thanks, can you share supported grafana dashboard link.

saiakhil46 avatar Apr 09 '21 08:04 saiakhil46

@tcurdt Thanks, can you share supported grafana dashboard link.

Not yet. Sorry. Probably worth getting in touch with people from the percona project if you don't want to create it yourself.

tcurdt avatar Apr 09 '21 10:04 tcurdt

Looks like it might be similar to #127 with the PR https://github.com/dcu/mongodb_exporter/pull/128

hloeung avatar Sep 12 '22 06:09 hloeung