##############################################################
# GMLM Platform — Prometheus Configuration
# Scrapes metrics from: app, mysql, redis, nginx, node_exporter
##############################################################

global:
  scrape_interval:     15s  # How often to scrape targets
  evaluation_interval: 15s  # How often to evaluate alert rules
  scrape_timeout:      10s

  # Attach these labels to all time series
  external_labels:
    deployment: 'gmlm-production'
    platform:   'gmlm'

# ── Alert rules ─────────────────────────────────────────────
rule_files:
  - /etc/prometheus/rules/gmlm.rules.yml

# ── Alertmanager ─────────────────────────────────────────────
alerting:
  alertmanagers:
    - static_configs:
        - targets: ['alertmanager:9093']

# ── Scrape configurations ────────────────────────────────────
scrape_configs:

  # Prometheus self-monitoring
  - job_name: prometheus
    static_configs:
      - targets: ['localhost:9090']

  # Laravel application metrics (via Laravel Pulse or custom /metrics endpoint)
  - job_name: gmlm_app
    metrics_path: /metrics
    bearer_token: '${METRICS_TOKEN}'
    static_configs:
      - targets: ['app:80']
    relabel_configs:
      - source_labels: [__address__]
        target_label:  instance

  # MySQL metrics via mysqld_exporter
  - job_name: mysql
    static_configs:
      - targets: ['mysql_exporter:9104']
    relabel_configs:
      - target_label: instance
        replacement: 'gmlm-mysql'

  # Redis metrics via redis_exporter
  - job_name: redis
    static_configs:
      - targets: ['redis_exporter:9121']
    relabel_configs:
      - target_label: instance
        replacement: 'gmlm-redis'

  # Nginx metrics via nginx-prometheus-exporter
  - job_name: nginx
    static_configs:
      - targets: ['nginx_exporter:9113']

  # Host system metrics via node_exporter
  - job_name: node
    static_configs:
      - targets: ['node_exporter:9100']
    relabel_configs:
      - source_labels: [__address__]
        regex:         '(.+):9100'
        target_label:  host
        replacement:   '$1'
