【Prometheus】

最近在研究 Prometheus ,发现遇到的很多问题,不知是不是我的搜索方式不对,根本找不到合适的解决方案,所以,自己动手丰衣足食。
以后会继续更新遇到的问题以及解决方案,希望对大家有帮助,如果有其他问题热烈欢迎私信或者评论区见。

问题一:监控云数据库 MongoDB 4.2 版本报错

问题描述

MongoDB版本升级后,mongodb_exporter 任务启动失败。

报错信息

Listening on 171.24.26.100:9625 (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=0x77cb0d]

goroutine 38 [running]:
github.com/dcu/mongodb_exporter/collector.(*PreloadStats).Export(0x0, 0xc0000a8c00)
        /root/go/src/github.com/dcu/mongodb_exporter/collector/metrics.go:363 +0x2d
github.com/dcu/mongodb_exporter/collector.(*ReplStats).Export(0xc00000e8e0, 0xc0000a8c00)
        /root/go/src/github.com/dcu/mongodb_exporter/collector/metrics.go:352 +0x90
github.com/dcu/mongodb_exporter/collector.(*MetricsStats).Export(0xc0000af9f0, 0xc0000a8c00)
        /root/go/src/github.com/dcu/mongodb_exporter/collector/metrics.go:448 +0x4ec
github.com/dcu/mongodb_exporter/collector.(*ServerStatus).Export(0xc0000bcc60, 0xc0000a8c00)
        /root/go/src/github.com/dcu/mongodb_exporter/collector/server_status.go:118 +0x2f2
github.com/dcu/mongodb_exporter/collector.(*MongodbCollector).collectServerStatus(0xc0000f2280, 0xc000093ba0, 0xc0000a8c00, 0xc000203e60)
        /root/go/src/github.com/dcu/mongodb_exporter/collector/mongodb_collector.go:144 +0xc3
github.com/dcu/mongodb_exporter/collector.(*MongodbCollector).Collect(0xc0000f2280, 0xc0000a8c00)
        /root/go/src/github.com/dcu/mongodb_exporter/collector/mongodb_collector.go:93 +0x2e8
github.com/dcu/mongodb_exporter/vendor/github.com/prometheus/client_golang/prometheus.(*Registry).Gather.func2(0xc0000a2b70, 0xc0000a8c00, 0x921ae0, 0xc0000f2280)
        /root/go/src/github.com/dcu/mongodb_exporter/vendor/github.com/prometheus/client_golang/prometheus/registry.go:433 +0x6b
created by github.com/dcu/mongodb_exporter/vendor/github.com/prometheus/client_golang/prometheus.(*Registry).Gather
        /root/go/src/github.com/dcu/mongodb_exporter/vendor/github.com/prometheus/client_golang/prometheus/registry.go:431 +0x2e9
Listening on 172.24.36.45:9625 (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=0x77cb0d]

问题解决

官网指定的 mongodb_exporter ( 下载地址),针对MongoDB4.0以上版本不兼容,需要重新安装新的 mongodb_exporter (下载地址),重新安装后,问题解决。


问题二:监控云数据库 MongoDB 3.2 版本报错

问题描述

在解决问题一的后,发现 mongodb_exporter 又有新的报错信息。

报错信息

time="2022-03-02T18:11:47+08:00" level=error msg="Failed to get replSetGetConfig: replSetGetConfig is forbidden by cloud provider for security reason, you can run `db.runCommand({listCommands: 1})` to get the supported command list, bad cmd: '{ replSetGetConfig: 1 }'." source="replset_conf.go:115"
time="2022-03-02T18:11:51+08:00" level=error msg="Failed to get replSetGetConfig: replSetGetConfig is forbidden by cloud provider for security reason, you can run `db.runCommand({listCommands: 1})` to get the supported command list, bad cmd: '{ replSetGetConfig: 1 }'." source="replset_conf.go:115"
time="2022-03-02T18:11:52+08:00" level=error msg="Failed to get replSetGetConfig: replSetGetConfig is forbidden by cloud provider for security reason, you can run `db.runCommand({listCommands: 1})` to get the supported command list, bad cmd: '{ replSetGetConfig: 1 }'." source="replset_conf.go:115"

问题解决

通过定位报错信息 db.runCommand({listCommands: 1}) ,原来云数据库版本不同会限制一些命令,详见(命令限制),listCommands 从mongodb_20190725_1.1.8版本开始支持,mongodb_20190409_1.1.7及之前版本不支持该命令,故升级小版本后,问题解决。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值