# TipSharks Prometheus Configuration
# Prometheus server scrape configuration for the TipSharks ELO API platform.

global:
  scrape_interval:     15s
  evaluation_interval: 15s
  external_labels:
    monitor: 'tipsharks'
    environment: 'production'

# Alerting configuration
alerting:
  alertmanagers:
    - static_configs:
        - targets:
          # Alertmanager endpoint — configure address when deployed
          # - alertmanager:9093

# Rule files to load
rule_files:
  - "alerts/*.yml"

# Scrape configurations
scrape_configs:

  # ---------- TipSharks API Service ----------
  - job_name: 'tipsharks-api'
    scrape_interval: 15s
    metrics_path: '/metrics'
    scheme: http
    static_configs:
      - targets:
          - 'api:8000'           # Docker compose service name
          - 'localhost:8000'     # Local development
        labels:
          service: 'tipsharks-api'
          component: 'api'

    # Relabeling to extract HTTP status code and endpoint labels
    metric_relabel_configs:
      - source_labels: [__name__]
        regex: 'tipsharks_api_requests_total'
        action: keep
      - source_labels: [__name__]
        regex: 'tipsharks_api_request_duration_seconds_.*'
        action: keep

  # ---------- PostgreSQL Exporter ----------
  - job_name: 'postgres-exporter'
    scrape_interval: 15s
    static_configs:
      - targets:
          - 'postgres-exporter:9187'   # Docker compose service
          - 'localhost:9187'            # Local development
        labels:
          service: 'postgres'
          component: 'database'

    params:
      # Disable SSL mode for internal connections
      sslmode: [disable]

  # ---------- Redis Exporter ----------
  - job_name: 'redis-exporter'
    scrape_interval: 15s
    static_configs:
      - targets:
          - 'redis-exporter:9121'    # Docker compose service
          - 'localhost:9121'          # Local development
        labels:
          service: 'redis'
          component: 'cache'

  # ---------- Node Exporter (host metrics) ----------
  - job_name: 'node-exporter'
    scrape_interval: 15s
    static_configs:
      - targets:
          - 'node-exporter:9100'
        labels:
          service: 'host'
          component: 'infrastructure'
