docker-compose.yml配置grafana、prometheus等監(jiān)控服務(wù)文件內(nèi)容

image.png

docker-compose.yml

version: '2.1'

networks:
    mynet:
        driver: bridge

services:

  prometheus:
    image: prom/prometheus
    container_name: prometheus_compose
    restart: always
    environment:
      web_backend: web_backend
      web: web
      mysql: mysql
      node-exporter: node-exporter
    ports:
      - "9090:9090"
    volumes:
      - ./prometheus.yml:/etc/prometheus/prometheus.yml
    networks:
      - mynet

  node-exporter:
    image: prom/node-exporter
    container_name: node_compose
    restart: always
    ports:
      - "9100:9100"
    environment:
      web_backend: web_backend
      web: web
      mysql: mysql
    networks:
      - mynet

  grafana:
    image: ubuntu_server:latest
    container_name: grafana_server
    restart: always
    ports:
      - "33000:3000"
      - "9104:9104"
    volumes:
      - ./docker/grafana/data/:/liaohuan/grafana/data
      - ./docker/grafana/conf:/liaohuan/grafana/conf
      - ./docker/mysql_exporter/.my.cnf:/root/.my.cnf
    networks:
      - mynet

  mysql:
    image: mysql:latest
    container_name: mysql
    restart: always
    ports:
      - "3309:3306"
    volumes:
      - ./docker/mysql/data:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=123456
    networks:
      - mynet

  web_backend:
    image: backend:v5
    container_name: web_backend
    restart: always
    ports:
      - "10088:10088"
      - "9099:9090"
      - "20022:22"
    links:
      - mysql
    depends_on:
      - mysql
      - prometheus
      - node-exporter
    environment:
      MYSQL_HOSTNAME: mysql
      FLASK_DEBUG: false
    volumes:
      - .:/home
      - ./docker/main.sh:/main.sh
      - ./requirements.txt:/homo/requirements.txt
    networks:
      - mynet
#    command: tail -f > /dev/null  # 阻塞服務(wù),方便進(jìn)入服務(wù)手動(dòng)啟動(dòng)和調(diào)試

  web:
    image: nginx:latest
    container_name: web
    restart: always
    ports:
      - "8088:80"
    links:
      - web_backend
    environment:
      web_backend: web_backend
    volumes:
      - ./docker/html:/usr/share/nginx/html
      - ./docker/nginx:/etc/nginx/conf.d
    networks:
      - mynet

prometheus.yml

global:
  scrape_interval: 15s

scrape_configs:
  - job_name: "prometheus"
    static_configs:
    - targets: ["127.0.0.1:9090"]

  - job_name: "node"
    static_configs:
    - targets: ["docker.for.mac.host.internal:9100"]

  - job_name: "mysql"
    static_configs:
      - targets: ["docker.for.mac.host.internal:9104"]

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容