docker-compose部署prometheus+grafana進行服務器監控

1、創建prometheus【prometheus.yml】配置

global: 
  scrape_interval:     15s 
  evaluation_interval: 15s 
 
scrape_configs: 
  - job_name: 'prometheus' 
    static_configs: 
      - targets: ['192.168.2.216:9090'] 
  - job_name: 'nodes' 
    static_configs: 
      - targets: ['192.168.25.250:19000'] #需要監控的節點node_exporte地址

2、創建【docker-compose.yml】

version: '3' 
 
services: 
  prometheus: 
    image: prom/prometheus 
    container_name: prometheus 
    ports: 
      - "9090:9090" 
    volumes: 
      - ./config/prometheus.yml:/etc/prometheus/prometheus.yml 
      - ./data:/prometheus

 

3、啓動prometheus

docker-compose up -d 

4、訪問服務

http://192.168.2.216:9090/graph

5、需要檢測的服務器部署檢測端node_exporte

version: '3' 
 
services: 
  node_exporter: 
    image: prom/node-exporter:v1.3.1
    container_name: node_exporter 
    ports: 
      - "19000:9100" 
    volumes: 
      - /proc:/host/proc:ro
      - /sys:/host/sys:ro
      - /:/rootfs:ro
    restart: always

啓動後,添加到prometheus.yml配置中

6、創建Grafana.yml

version: '3' 
 
services: 
  grafana:
    image: grafana/grafana
    container_name: "grafana"
    ports:
      - "3000:3000"
    restart: always
    volumes:
      - "./grafana_data:/var/lib/grafana"

 訪問地址:http://192.168.2.216:3000/    賬號密碼:admin/admin

7、添加Prometheus

 

 8、添加dashboards

進入官網下載dashboards

Dashboards | Grafana Labs

下載文件:Node Exporter Full | Grafana Labs

 

 

 9、效果

 

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