# Copyright (c) Abstract Machines
# SPDX-License-Identifier: Apache-2.0

# This docker-compose file contains optional Prometheus and Grafana service for SuperMQ platform.
# Since this service is optional, this file is dependent of docker-compose.yaml file
# from <project_root>/docker. In order to run this service, execute command:
# docker compose -f docker/addons/prometheus/docker-compose.yaml up
# from project root.

networks:
  supermq-base-net:
    name: supermq-base-net
    external: true

volumes:
  supermq-prometheus-volume:


services:
  promethues:
    image: prom/prometheus:v2.49.1
    container_name: supermq-prometheus
    restart: on-failure
    ports:
      - ${SMQ_PROMETHEUS_PORT}:${SMQ_PROMETHEUS_PORT}
    networks:
      - supermq-base-net
    volumes:
      - type: bind
        source: ./metrics/prometheus.yaml
        target: /etc/prometheus/prometheus.yaml
      - supermq-prometheus-volume:/prometheus

  grafana:
    image: grafana/grafana:10.2.3
    container_name: supermq-grafana
    depends_on:
      - promethues
    restart: on-failure
    ports:
      - ${SMQ_GRAFANA_PORT}:${SMQ_GRAFANA_PORT}
    environment:
      - GF_SECURITY_ADMIN_USER=${SMQ_GRAFANA_ADMIN_USER}
      - GF_SECURITY_ADMIN_PASSWORD=${SMQ_GRAFANA_ADMIN_PASSWORD}
    networks:
      - supermq-base-net
    volumes:
      - type: bind
        source: ./grafana/datasource.yaml
        target: /etc/grafana/provisioning/datasources/datasource.yaml
      - type: bind
        source: ./grafana/dashboard.yaml
        target: /etc/grafana/provisioning/dashboards/main.yaml
      - type: bind
        source: ./grafana/example-dashboard.json
        target: /var/lib/grafana/dashboards/example-dashboard.json
