# Prometheus configuration for ChatApp monitoring
# Security: basic auth on scrape targets, retention configured via compose

global:
  scrape_interval: 15s
  evaluation_interval: 15s
  external_labels:
    cluster: chatapp
    environment: production

rule_files:
  - /etc/prometheus/rules/alerts.yml

alerting:
  alertmanagers:
    - static_configs:
        - targets: ['alertmanager:9093']

scrape_configs:
  # API metrics — scrape /metrics endpoint
  - job_name: 'chatapp-api'
    static_configs:
      - targets: ['api:3010']
        labels:
          service: api
    metrics_path: /metrics
    scrape_interval: 10s
    scrape_timeout: 5s
    scheme: http

  # WebSocket metrics — scrape /metrics endpoint
  - job_name: 'chatapp-realtime'
    static_configs:
      - targets: ['realtime:3002']
        labels:
          service: realtime
    metrics_path: /metrics
    scrape_interval: 10s
    scrape_timeout: 5s
    scheme: http

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

  # PostgreSQL metrics (needs postgres_exporter)
  - job_name: 'postgres'
    static_configs:
      - targets: ['postgres-exporter:9187']
        labels:
          service: postgres
    scrape_interval: 30s
    scrape_timeout: 10s

  # Redis metrics (needs redis_exporter)
  - job_name: 'redis'
    static_configs:
      - targets: ['redis-exporter:9121']
        labels:
          service: redis
    scrape_interval: 15s
    scrape_timeout: 5s

  # Node exporter (system metrics)
  - job_name: 'node'
    static_configs:
      - targets: ['node-exporter:9100']
        labels:
          service: node
    scrape_interval: 15s
    scrape_timeout: 5s