dcu / mongodb_exporter

MongoDB exporter for prometheus.io
MIT License
353 stars 216 forks source link

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

Open Bodenhaltung opened 3 years ago

Bodenhaltung commented 3 years ago

Hi,

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

./mongodb_exporter-linux-amd64 -mongodb.uri "mongodb://user:password@127.0.0.1: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
tcurdt commented 3 years ago

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

saiakhil46 commented 3 years ago

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

tcurdt commented 3 years ago

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

saiakhil46 commented 3 years ago

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

tcurdt commented 3 years ago

@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.

hloeung commented 2 years ago

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