카이도스의 Tech Blog

mongodb_exporter 설치 본문

모니터링

mongodb_exporter 설치

카이도스 2024. 2. 4. 14:31
728x90
반응형
  • mongodb_exporter 설치
# 설치
sudo su -
wget https://github.com/percona/mongodb_exporter/releases/download/v0.40.0/mongodb_exporter-0.40.0.linux-64-bit.deb
dpkg -i mongodb_exporter-0.40.0.linux-64-bit.deb

# 환경설정
cd /etc/systemd/system/
vi mongodb_exporter.service
[Unit]
Description=Prometheus MongoDB Exporter
Documentation=https://github.com/percona/mongodb_exporter
After=network.target

[Service]
Type=simple

User=ubuntu
Group=ubuntu

EnvironmentFile=-/etc/default/mongodb_exporter
ExecStart=/usr/bin/mongodb_exporter --mongodb.uri=mongodb://mongodb_exporter:password@IP:27017 --compatible-mode --collect-all
SyslogIdentifier=mongodb_exporter

Restart=always

[Install]
WantedBy=multi-user.target

# 게정 생성
mongosh
use admin
db.createUser(
  {
    user: "mongodb_exporter",
    pwd: "password",
    roles: [
        { role: "clusterMonitor", db: "admin" },
        { role: "read", db: "local" }
    ]
  }
)

# 재기동
sudo systemctl daemon-reload
sudo systemctl restart mongodb_exporter.service
sudo systemctl enable mongodb_exporter.service
sudo systemctl status mongodb_exporter.service

# 확인
curl localhost:9216/metrics

  • Prometheus 설정
# prometheus.yml 수정 (targets 추가, alias 임의 설정)
sudo vi /etc/prometheus/prometheus.yml
- job_name: 'prd-mongo'
    static_configs:
      - targets: ['IP:9216']

# prometheus 데몬 재기동
sudo systemctl restart prometheus.service
sudo systemctl status prometheus
728x90
반응형

'모니터링' 카테고리의 다른 글

nGrinder 설치  (0) 2024.02.28
Redis Exporter  (1) 2024.02.04
Grafana, Loki, Promtail 모니터링+로그 셋팅+zabbix 연동  (0) 2023.04.26
Datadog Agent 설치  (0) 2023.04.04
DATADOG-AWS 연동  (0) 2023.03.29
Comments