基於docker 搭建Prometheus+Grafana的過程詳解

1. 拉取依賴鏡像

docker pull prom/node-exporter
docker pull prom/prometheus
docker pull grafana/grafana

2.分別啓動各鏡像

  1. 啓動node-exporter

    docker run -d -p 9100:9100 \
     --name node-exporter \
     --restart=always  \
     -v /opt/dockerData/node-exporter/proc:/host/proc:ro \
     -v /opt/dockerData/node-exporter/sys:/host/sys:ro \
     -v /opt/dockerData/node-exporter:/rootfs:ro \
     prom/node-exporter
    
  2. 啓動promethus

    docker run -d \
     --name prometheus \
     --restart=always \
     -u root \
     -p 9090:9090 \
     -v /opt/dockerData/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml \
     -v /opt/dockerData/prometheus:/prometheus \
     -v /opt/dockerData/prometheus/conf:/etc/prometheus/conf \
     prom/prometheus
    

    prometheus.yml

    global:
      scrape_interval: 60s
      evaluation_interval: 60s
    
    scrape_configs:
      - job_name: prometheus
        static_configs:
          - targets:
              - 192.168.0.104:9090
    
      - job_name: node-exporter
        static_configs:
          - targets:
              - 192.168.0.104:9100
    
  3. 啓動grafana

    docker run -d \
     -p 3000:3000 \
     --restart=always \
     --name=grafana \
     -u root \
     -v /opt/dockerData/grafana:/var/lib/grafana \
     grafana/grafana
    

3.登錄grafana

默認用戶名和密碼均爲admin,登錄成功後修改默認密碼

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章