5.监控mongodb(mongodb_exporter)

文章目录

github地址:https://github.com/percona/mongodb_exporter
下载地址:https://github.com/percona/mongodb_exporter/releases

1.下载并授权

mkdir -p /opt/plg/mongodb_exporter 
cd /opt/plg/tools
"这里注意一下,新版本的mongodb_exporter 提供的查询接口和目前的grafana 模版调用不一致,不会显示数据"
# wget https://github.com/percona/mongodb_exporter/releases/download/v0.20.1/mongodb_exporter-0.20.1.linux-amd64.tar.gz
wget https://github.com/percona/mongodb_exporter/releases/download/v0.11.2/mongodb_exporter-0.11.2.linux-amd64.tar.gz
tar -xvf mongodb_exporter-0.11.2.linux-amd64.tar.gz
mv mongodb_exporter ../mongodb_exporter/
cd ../mongodb_exporter && chmod a+x mongodb_exporter

2.启动并指定端口

--mongodb.uri 只能连接一个ip:port ,连接多个会报错,我们只能修改它连接后产生的web ui 端口
./mongodb_exporter  --web.listen-address=":35117" --mongodb.uri=mongodb://admin:w3MaA8jHKG5DbXtX@192.168.11.161:25117/admin?replicaSet=testDB&&authSource=admin

3.systemd启动

cat >/usr/lib/systemd/system/mongodb1_exporter.service <<EOF
[Unit]
Description=mongodb_exporter
After=network.target
Documentation= https://github.com/percona/mongodb_exporter
[Service]
Type=simple
ExecStart=/opt/plg/mongodb_exporter/mongodb_exporter \\
--mongodb.uri=mongodb://admin:w3MaA8jHKG5DbXtX@192.168.11.161:25117 --web.listen-address=:35117
Restart=on-failure
[Install]
WantedBy=multi-user.target
EOF

4.修改prometheus 配置文件

vim prometheus.yaml
scrape_configs:
...
# mongodb监控
  - job_name: "mongodb_exporter_pod"
    #metrics_path: '/metrics'
    static_configs:
      - targets: ['192.168.11.175:35117']
        labels:
          unitname: "Mongodb_exporter"

5.导入模板

导入模板 2583
https://grafana.com/grafana/dashboards/2583
上一篇:prometheus 普罗米修斯安装


下一篇:Prometheus监控系统_Alertmanager告警【Email_企业微信】