美文网首页
docker-compose.yml配置grafana、prom

docker-compose.yml配置grafana、prom

作者: 烤奶要加冰 | 来源:发表于2023-06-27 18:33 被阅读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"]
    
    

    相关文章

      网友评论

          本文标题:docker-compose.yml配置grafana、prom

          本文链接:https://www.haomeiwen.com/subject/edunydtx.html