docker-compose部署prometheus

228 阅读1分钟

1、主节点docker-compose.yml

去掉了​​altermanager​​​和​​dingtalk​​告警的部署

prometheus server节点prometheus node_exporter grafana三个组件都需要部署

version: '3.7'
services:
  node-exporter:
    image: prom/node-exporter:latest
    ports:
      - "9100:9100"
    networks:
      - prom

#  dingtalk:
#    image: timonwong/prometheus-webhook-dingtalk:latest
#    volumes:
#      - type: bind
#        source: ./alertmanager/config.yml
#        target: /etc/prometheus-webhook-dingtalk/config.yml
#        read_only: true
#    ports:
#      - "8060:8060"
#    networks:
#      - prom

#  alertmanager:
#    depends_on:
#      - dingtalk
#    image: prom/alertmanager:latest
#    volumes:
#      - type: bind
#        source: ./alertmanager/alertmanager.yml
#        target: /etc/alertmanager/alertmanager.yml
#        read_only: true
#    ports:
#      - "9093:9093"
#     - "9094:9094"
#    networks:
#      - prom

  prometheus:
    image: prom/prometheus:latest
    volumes:
      - type: bind
        source: ./prometheus/prometheus.yml
        target: /etc/prometheus/prometheus.yml
        read_only: true
      - type: volume
        source: prometheus
        target: /prometheus
    ports:
      - "9090:9090"
    networks:
      - prom

  grafana:
    depends_on:
      - prometheus
    image: grafana/grafana:latest
    volumes:
      - type: volume
        source: grafana
        target: /var/lib/grafana
    ports:
      - "3000:3000"
    networks:
      - prom

volumes:
  prometheus:
    driver: local
    driver_opts:
      type: none
      o: bind
      device: /opt/dmgeo/prom/prometheus/data
  grafana:
    driver: local
    driver_opts:
      type: none
      o: bind
      device: /opt/dmgeo/prom/grafana

networks:
  prom:
    driver: bridge

prometheus.yml

global:
  scrape_interval:     15s
  evaluation_interval: 15s

#alerting:
#  alertmanagers:
#  - static_configs:
#    - targets:
#      - alertmanager:9093

rule_files:
  - "*rules.yml"

scrape_configs:
  - job_name: 'prometheus'
    static_configs:
    - targets: ['prometheus:9090']

  - job_name: 'node'
    static_configs:
    - targets: ['node-exporter:9100','192.168.123.12:9100','192.168.123.13:9100']

#  - job_name: 'alertmanager'
#    static_configs:
#    - targets: ['alertmanager:9093']

从节点docker-compose.yaml

version: '3.7'
services:
  node-exporter:
    image: prom/node-exporter:latest
    ports:
      - "9100:9100"