Prometheus docker-compose安装部署文档

备注:以下操作均在root权限下进行的操作

安装前置环境:

已安装docker

已安装docker-compose

在/opt目录新建目录prom

在对应的prom目录下分别创建prometheus、alertmanager,grafana相关目录

mkdir -p /opt/prom/{prometheus,prometheus/data,alertmanager,grafana}
#prom目录结构
prom/
├── alertmanager
├── grafana
└── prometheus
    └── data

赋予相关目录对应的权限

chmod 777 /opt/prom/{prometheus/data,grafana}

编写docker-compose.yml文件,放在目录/opt/prom下

touch /opt/prom/docker-compose.yml
vim /opt/prom/docker-compose.yml

docker-compose.yml文件内容

version: '3.3'
 
services:
  node-exporter:
    image: prom/node-exporter:latest
    ports:
      - "9101:9100"         #node-exporter默认端口9100,不过由于metersphere的node-exporter已经占用了9100了,这里调整为9101
    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:
    depends_on:
      - alertmanager
    image: prom/prometheus:latest
    volumes:
      - type: bind
        source: ./prometheus/prometheus.yml
        target: /etc/prometheus/prometheus.yml
        read_only: true
      - type: bind
        source: ./prometheus/alert-rules.yml
        target: /etc/prometheus/alert-rules.yml
        read_only: true
      - type: volume
        source: prometheus
        target: /prometheus
    ports:
      - "9200:9090"         #prometheus默认端口9090,不过ms-prometheus占用该端口,这里换成9200
    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/prom/prometheus/data
  grafana:
    driver: local
    driver_opts:
      type: none
      o: bind
      device: /opt/prom/grafana
 
networks:
  prom:
    driver: bridge

编写prometheus的配置文件prometheus.yml,放在/opt/prom/prometheus目录下

touch /opt/prom/prometheus/prometheus.yml
vim /opt/prom/prometheus/prometheus.yml
global:
  scrape_interval:     15s
  evaluation_interval: 15s
 
alerting:
  alertmanagers:
  - static_configs:
    - targets:
      - alertmanager:9093
 
rule_files:
  - "*rules.yml&
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值