dcu / mongodb_exporter

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

mongodb exporter crashes #127

Open vkuznet opened 4 years ago

vkuznet commented 4 years ago

I'm unable to run mongodb exporter it always crashes either on Linux (within k8s) or locally on OSX. The error I got is always the same, see below the output from OSX crash. I run MongoDB locally, it does not have any replicas, etc, very basic setup. But error seems to be related to replica sets which I explicitly turned off. The error occurs every time I start querying the mongodb_exporter server via curl command. Any ideas?

mongodb_exporter-darwin-amd64 -mongodb.uri "mongodb://localhost:8230" -mongodb.collect.replset=false -mongodb.collect.oplog=false -alsologtostderr
Listening on :9001 (scheme=HTTP, secured=no, clientValidation=no)
I0625 15:22:31.202532   13887 mongodb_collector.go:63] Collecting Server Status
I0625 15:22:31.222753   13887 mongodb_collector.go:84] exporting ServerStatus Metrics
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x1087c8]

goroutine 22 [running]:
panic(0x344640, 0xc420018100)
    /usr/local/go/src/runtime/panic.go:500 +0x1a1
github.com/dcu/mongodb_exporter/collector.(*PreloadStats).Export(0x0, 0xc420196180)
    /Users/dc/code/go/src/github.com/dcu/mongodb_exporter/collector/metrics.go:363 +0x38
github.com/dcu/mongodb_exporter/collector.(*ReplStats).Export(0xc420247380, 0xc420196180)
    /Users/dc/code/go/src/github.com/dcu/mongodb_exporter/collector/metrics.go:352 +0x90
github.com/dcu/mongodb_exporter/collector.(*MetricsStats).Export(0xc4201cbf40, 0xc420196180)
    /Users/dc/code/go/src/github.com/dcu/mongodb_exporter/collector/metrics.go:435 +0x4c7
github.com/dcu/mongodb_exporter/collector.(*ServerStatus).Export(0xc4200af720, 0xc420196180)
    /Users/dc/code/go/src/github.com/dcu/mongodb_exporter/collector/server_status.go:111 +0x1f9
github.com/dcu/mongodb_exporter/collector.(*MongodbCollector).collectServerStatus(0xc4200165f0, 0xc42007bd40, 0xc420196180, 0x329f00)
    /Users/dc/code/go/src/github.com/dcu/mongodb_exporter/collector/mongodb_collector.go:85 +0xe3
github.com/dcu/mongodb_exporter/collector.(*MongodbCollector).Collect(0xc4200165f0, 0xc420196180)
    /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(0xc42017c0f0, 0xc420196180, 0x534d00, 0xc4200165f0)
    /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
GOrtiz16 commented 4 years ago

Hi, I have the same problem. Did you solve it?

vkuznet commented 4 years ago

yes, I applied this change: https://github.com/vkuznet/mongodb_exporter/commit/9a287e6f7e8a9df2f573306db1689f33b401d091

hloeung commented 2 years ago

128