# =============================================================================
# Prometheus Configuration for RE Workflow
# =============================================================================

global:
  scrape_interval: 15s          # How frequently to scrape targets
  evaluation_interval: 15s       # How frequently to evaluate rules
  external_labels:
    monitor: 're-workflow-monitor'
    environment: 'development'

# Alerting configuration
alerting:
  alertmanagers:
    - static_configs:
        - targets:
            - alertmanager:9093

# Rule files
rule_files:
  - /etc/prometheus/alert.rules.yml

# Scrape configurations
scrape_configs:
  # ============================================
  # Prometheus Self-Monitoring
  # ============================================
  - job_name: 'prometheus'
    static_configs:
      - targets: ['localhost:9090']
        labels:
          service: 'prometheus'

  # ============================================
  # RE Workflow Backend API Metrics
  # ============================================
  - job_name: 're-workflow-backend'
    static_configs:
      # Option 1: Backend running locally (outside Docker monitoring stack)
      - targets: ['host.docker.internal:5000']
        labels:
          service: 'backend'
          environment: 'development'
          deployment: 'local'
      # Option 2: Backend running in Docker (docker-compose.full.yml)
      # Uncomment below and comment above when using full stack
      # - targets: ['re_workflow_backend:5000']
      #   labels:
      #     service: 'backend'
      #     environment: 'development'
      #     deployment: 'docker'
    metrics_path: /metrics
    scrape_interval: 10s
    scrape_timeout: 5s
    authorization:
      credentials: 're_c92b9cf291d2be65a1704207aa25352d69432b643e6c9e9a172938c964809f2d'

  # ============================================
  # Node Exporter - Host Metrics
  # ============================================
  - job_name: 'node-exporter'
    static_configs:
      - targets: ['node-exporter:9100']
        labels:
          service: 'node-exporter'

  # ============================================
  # PostgreSQL Metrics (if using pg_exporter)
  # ============================================
  # - job_name: 'postgres'
  #   static_configs:
  #     - targets: ['postgres-exporter:9187']
  #       labels:
  #         service: 'postgresql'

  # ============================================
  # Redis Metrics
  # ============================================
  - job_name: 'redis'
    static_configs:
      - targets: ['redis-exporter:9121']
        labels:
          service: 'redis'
          environment: 'development'

  # ============================================
  # Loki Metrics
  # ============================================
  - job_name: 'loki'
    static_configs:
      - targets: ['loki:3100']
        labels:
          service: 'loki'

  # ============================================
  # Grafana Metrics
  # ============================================
  - job_name: 'grafana'
    static_configs:
      - targets: ['grafana:3000']
        labels:
          service: 'grafana'

