25 Ekim 2022 Salı

Docker Compose ve Prometheus

Örnek
Şöyle yaparız
version: "3"
services:
  app:
    image: quiz-server:latest
    container_name: 'quiz-server'
    build:
      context: ./
      dockerfile: Dockerfile
    ports:
    - '8080:8080'
  prometheus:
    image: prom/prometheus
    container_name: 'prometheus'
    volumes:
    - ./monitor/:/etc/prometheus/
    ports:
    - '9090:9090'
  grafana:
    image: grafana/grafana
    container_name: 'grafana'
    ports:
    - '3000:3000'
    depends_on:
    - prometheus
Örnek
Şöyle yaparız
services:
  prometheus:
      image: prom/prometheus:v2.35.0
      network_mode: host
      container_name: prometheus
      restart: unless-stopped
      volumes:
        - ./data/prometheus/config:/etc/prometheus/
      command:
        - "--config.file=/etc/prometheus/prometheus.yaml"
Örnek
Şöyle yaparız
version: "3.8"

services:
  prometheus:
    container_name: prometheus
    image: prom/prometheus:v2.44.0
    user: root
    volumes:
      - ./prometheus:/etc/prometheus
    command:
      - --config.file=/etc/prometheus/prometheus-config.yaml
      - --log.level=debug
    ports:
      - "9090:9090"
    networks:
      - prometheus-network

networks:
 prometheus-network:
./prometheus/prometheus-config.yaml dosyası Prometheus tarafından /etc/prometheus/prometheus-config.yaml olarak görülür

node_exporter
node_exporter ile işletim sistemini de izlemek mümkün. 
Örnek 
Şöyle yaparız
version: "3.9"

services:
  microservices_postgresql:
    image: postgres:latest
    container_name: microservices_postgresql
    expose:
      - "5432"
    ports:
      - "5432:5432"
    restart: always
    environment:
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=postgres
      - POSTGRES_DB=bank_accounts
      - POSTGRES_HOST=5432
    command: -p 5432
    volumes:
      - ./docker_data/microservices_pgdata:/var/lib/postgresql/data
    networks: [ "microservices" ]

  redis:
    image: redis:latest
    container_name: microservices_redis
    ports:
      - "6379:6379"
    restart: always
    networks: [ "microservices" ]

  prometheus:
    image: prom/prometheus:latest
    container_name: prometheus
    ports:
      - "9090:9090"
    command:
      - --config.file=/etc/prometheus/prometheus.yml
    volumes:
      - ./monitoring/prometheus.yml:/etc/prometheus/prometheus.yml:ro
    networks: [ "microservices" ]

  node_exporter:
    container_name: microservices_node_exporter
    restart: always
    image: prom/node-exporter
    ports:
      - '9101:9100'
    networks: [ "microservices" ]

  grafana:
    container_name: microservices_grafana
    restart: always
    image: grafana/grafana
    ports:
      - '3000:3000'
    networks: [ "microservices" ]

  zipkin:
    image: openzipkin/zipkin:latest
    restart: always
    container_name: microservices_zipkin
    ports:
      - "9411:9411"
    networks: [ "microservices" ]


networks:
  microservices:
    name: microservices

Hiç yorum yok:

Yorum Gönder