Рет қаралды 8,781
This tutorial helps you to setup MongoDB monitoring with the help of Prometheus & Grafana.
Below are the commands that has been used in this tutorial:
mkdir mongodb-exporter
cd mongodb-exporter
wget github.com/per...
tar xvzf mongodb_exporter-0.7.1.linux-amd64.tar.gz
sudo useradd -rs /bin/false prometheus
sudo mv mongodb_exporter /usr/local/bin/
mongo --port 27017
use admin
db.createUser(
{
user: "mongodb_exporter",
pwd: "password",
roles: [
{ role: "clusterMonitor", db: "admin" },
{ role: "read", db: "local" }
]
}
)
exit
sudo mongod --auth --port 27017 --config /etc/mongodb.conf &
export MONGODB_URI=mongodb://mongodb_exporter:password@localhost:27017
cd /lib/systemd/system/
sudo touch mongodb_exporter.service
[Unit]
Description=MongoDB Exporter
User=prometheus
[Service]
Type=simple
Restart=always
ExecStart=/usr/local/bin/mongodb_exporter --mongodb.uri=mongodb://mongodb_exporter:password@localhost:27017
[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl start mongodb_exporter.service
Edit Prometheus Conf File
- job_name: 'prometheus'
static_configs:
- targets: ['IP_ADRESS:9090', 'IP_ADRESS:9216']
Restart Prometheus Server