docker-compose.yml配置grafana、prom

2023-06-27  本文已影响0人  烤奶要加冰
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  # 阻塞服务,方便进入服务手动启动和调试

  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"]

上一篇下一篇

猜你喜欢

热点阅读