networks:
  monitoring:
    external: false

services:
  prometheus:
    image: docker.io/prom/prometheus
    container_name: prometheus
    restart: always
    ports:
      - '127.0.0.1:9090:9090'
    volumes:
      - prometheus-data:/prometheus
      - /opt/beeserver/monitoring/prometheus.yml:/etc/prometheus/prometheus.yml
    networks:
      - monitoring

  grafana:
    image: docker.io/grafana/grafana
    container_name: grafana
    restart: always
    ports:
      - '4000:4000'
    volumes:
      - grafana-storage:/var/lib/grafana
    environment:
      - GF_SECURITY_SECRET_KEY={{ grafana_secret }}
      - GF_SERVER_DOMAIN=grafana.secretbee.buzz
      - GF_SERVER_ROOT_URL=https://grafana.secretbee.buzz/
      - GF_SERVER_HTTP_PORT=4000
      - GF_SERVER_PROTOCOL=HTTP
    networks:
      - monitoring

  loki:
    image: docker.io/grafana/loki
    container_name: loki
    ports:
      - '127.0.0.1:3100:3100'
      - '127.0.0.1:9096:9096'
    volumes:
      - loki-data:/loki
      - /opt/beeserver/monitoring/local-config.yml:/etc/loki/local-config.yaml
    command: -config.file=/etc/loki/local-config.yaml
    restart: always
    networks:
      - monitoring

  alloy:
    image: docker.io/grafana/alloy
    container_name: alloy
    ports:
      - '127.0.0.1:12345:12345'
    volumes:
      - /opt/beeserver/monitoring/config.alloy:/etc/alloy/config.alloy
      - /opt/beeserver/monitoring/database:/opt/database
      - /var/log:/var/log:ro
      - /run/log/journal:/run/log/journal:ro
      - /var/log/journal:/var/log/journal:ro
      - /etc/machine-id:/etc/machine-id:ro
      - alloy-data:/var/lib/alloy/data
    command:
      - run
      - /etc/alloy/config.alloy
      - --storage.path=/var/lib/alloy/data
      - --server.http.listen-addr=0.0.0.0:12345
      - --stability.level=experimental
    networks:
      - monitoring
    restart: always

  podman-exporter:
    image: quay.io/navidys/prometheus-podman-exporter
    container_name: podman-exporter
    restart: always
    privileged: true
    user: root
    ports:
      - '127.0.0.1:9882:9882'
    volumes:
      - /run/podman/podman.sock:/run/podman/podman.sock
    environment:
      - CONTAINER_HOST=unix:///run/podman/podman.sock
    security_opt:
      - label=disable
    networks:
      - monitoring

volumes:
  prometheus-data:
  grafana-storage:
  loki-data:
  alloy-data: