Ⅰ. はじめに
タイトルの通り「Prometheus + Node exporter + Grafanaを利用してテレメトリデータをグラフ化する方法」です。
Ⅱ. 手順
1. 新規ディレクトリを作成する
mkdir telemetry
2. 新規ファイルを作成する
telemetry/prometheus/prometheus.yml
global: scrape_interval: 15s evaluation_interval: 15s scrape_configs: - job_name: "prometheus" static_configs: - targets: ["127.0.0.1:9090"] - job_name: "node" static_configs: - targets: ["127.0.0.1:9100"]
telemetry/docker-compose.yml
version: '3.8' services: prometheus: image: prom/prometheus container_name: prometheus network_mode: host expose: - 9090 restart: unless-stopped volumes: - prometheus:/prometheus - ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml node_exporter: image: quay.io/prometheus/node-exporter:latest container_name: node_exporter command: - '--path.rootfs=/host' network_mode: host pid: host restart: unless-stopped volumes: - '/:/host:ro,rslave' grafana: image: grafana/grafana container_name: grafana network_mode: host expose: - 3000 restart: unless-stopped volumes: - grafana:/var/lib/grafana volumes: prometheus: {} grafana: {}
3. Dockerコンテナを起動する
docker-compose up -d
4. WebブラウザでPrometheusにアクセスする
Node exporter の接続状態を確認する
4. WebブラウザでGrafanaにアクセスする
URL | http://127.0.0.1:3000 |
初期ユーザー名 | admin |
初期パスワード | admin |
5. GrafanaのデータソースにPrometheusを指定する
6. Grafanaにグラフを追加する
実行結果
留意点
- ファイアウォール設定を適切に行う