version: '3.8'

services:
  kafka:
    image: wurstmeister/kafka:latest
    container_name: kafka
    environment:
      KAFKA_ADVERTISED_LISTENERS: INSIDE://kafka:9093,OUTSIDE://localhost:9092
      KAFKA_LISTENERS: INSIDE://0.0.0.0:9093,OUTSIDE://0.0.0.0:9092
      KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: INSIDE:PLAINTEXT,OUTSIDE:PLAINTEXT
      KAFKA_LISTENER_NAME_PLAINTEXT: INSIDE,OUTSIDE
      KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
      KAFKA_ZOOKEEPER_CONNECT_TIMEOUT_MS: 60000
      KAFKA_ZOOKEEPER_SESSION_TIMEOUT_MS: 60000
      KAFKA_INTER_BROKER_LISTENER_NAME: INSIDE  # Добавлено
    ports:
      - "9092:9092"  # OUTSIDE
      - "9093:9093"  # INSIDE
    depends_on:
      - zookeeper

  zookeeper:
    image: wurstmeister/zookeeper:latest
    container_name: zookeeper
    environment:
      ZOOKEEPER_CLIENT_PORT: 2181
    ports:
      - "2181:2181"

  otel-collector:
    image: otel/opentelemetry-collector-contrib:0.104.0
    container_name: otel-collector
    command: ["--config", "/etc/otelcol-contrib/config.yaml"]
    ports:
      - "4317:4317"  # gRPC
      - "4318:4318"  # HTTP
      - "9999:9999"  # Prometheus (обновлено)
    volumes:
      - ./otel-collector-config.yaml:/etc/otelcol-contrib/config.yaml

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

  grafana:
    image: grafana/grafana:latest
    container_name: grafana
    ports:
      - "3000:3000"
    volumes:
      - grafana-storage:/var/lib/grafana

volumes:
  grafana-storage:
