# ===================================================================
# Prometheus Development Configuration
# Enhanced monitoring for Meldestelle development environment
# ===================================================================

global:
  scrape_interval: 15s      # More frequent scraping for development
  evaluation_interval: 15s  # Faster rule evaluation
  external_labels:
    cluster: 'meldestelle-dev'
    environment: 'development'

# Rule files for alerting (development-friendly)
rule_files:
  - "/etc/prometheus/rules.yml"

# Scrape configurations for development services
scrape_configs:
  # ===================================================================
  # Infrastructure Services
  # ===================================================================

  # Prometheus self-monitoring
  - job_name: 'prometheus'
    static_configs:
      - targets: ['localhost:9090']
    scrape_interval: 15s
    metrics_path: '/metrics'

  # ===================================================================
  # Application Services (Spring Boot)
  # ===================================================================

  # API Gateway
  - job_name: 'api-gateway'
    static_configs:
      - targets: ['api-gateway:8081']
    metrics_path: '/actuator/prometheus'
    scrape_interval: 10s  # More frequent for gateway
    scrape_timeout: 5s
    params:
      format: ['prometheus']

  # Auth Server
  - job_name: 'auth-server'
    static_configs:
      - targets: ['auth-server:8081']
    metrics_path: '/actuator/prometheus'
    scrape_interval: 15s
    scrape_timeout: 5s

  # Monitoring Server (self-monitoring)
  - job_name: 'monitoring-server'
    static_configs:
      - targets: ['monitoring-server:8083']
    metrics_path: '/actuator/prometheus'
    scrape_interval: 15s
    scrape_timeout: 5s

  # Ping Service
  - job_name: 'ping-service'
    static_configs:
      - targets: ['ping-service:8082']
    metrics_path: '/actuator/prometheus'
    scrape_interval: 10s  # Frequent for testing
    scrape_timeout: 3s

  # ===================================================================
  # Infrastructure Monitoring
  # ===================================================================

  # PostgreSQL Exporter (if deployed)
  - job_name: 'postgres'
    static_configs:
      - targets: ['postgres-exporter:9187']
    scrape_interval: 30s
    scrape_timeout: 10s

  # Redis Exporter (if deployed)
  - job_name: 'redis'
    static_configs:
      - targets: ['redis-exporter:9121']
    scrape_interval: 30s
    scrape_timeout: 10s

  # ===================================================================
  # Container and Host Metrics
  # ===================================================================

  # Docker container metrics via cAdvisor (if deployed)
  - job_name: 'cadvisor'
    static_configs:
      - targets: ['cadvisor:8080']
    scrape_interval: 30s
    scrape_timeout: 10s

  # Node Exporter for host metrics (if deployed)
  - job_name: 'node-exporter'
    static_configs:
      - targets: ['node-exporter:9100']
    scrape_interval: 30s
    scrape_timeout: 10s

  # ===================================================================
  # Service Discovery (Consul Integration)
  # ===================================================================

  # Consul service discovery for dynamic services
  - job_name: 'consul-services'
    consul_sd_configs:
      - server: 'consul:8500'
        services: []
    relabel_configs:
      # Only scrape services that have prometheus.scrape=true
      - source_labels: [__meta_consul_service_metadata_prometheus_scrape]
        action: keep
        regex: "true"

      # Use service name as job name
      - source_labels: [__meta_consul_service]
        target_label: job

      # Use custom metrics path if specified
      - source_labels: [__meta_consul_service_metadata_prometheus_path]
        target_label: __metrics_path__
        regex: "(.+)"

      # Use custom port if specified
      - source_labels: [__address__, __meta_consul_service_metadata_prometheus_port]
        target_label: __address__
        regex: "([^:]+)(?::\d+)?;(\d+)"
        replacement: $1:$2

  # ===================================================================
  # Development-Specific Configurations
  # ===================================================================

  # Health check endpoints monitoring
  - job_name: 'health-checks'
    static_configs:
      - targets:
          - 'api-gateway:8081'
          - 'auth-server:8081'
          - 'monitoring-server:8083'
          - 'ping-service:8082'
    metrics_path: '/actuator/health'
    scrape_interval: 30s
    scrape_timeout: 5s

  # JVM metrics (additional detail for development)
  - job_name: 'jvm-metrics'
    static_configs:
      - targets:
          - 'api-gateway:8081'
          - 'auth-server:8081'
          - 'monitoring-server:8083'
          - 'ping-service:8082'
    metrics_path: '/actuator/prometheus'
    scrape_interval: 30s
    params:
      match[]:
        - 'jvm_*'
        - 'process_*'
        - 'system_*'

# ===================================================================
# Alerting Configuration (Development-friendly)
# ===================================================================
alerting:
  alertmanagers:
    - static_configs:
        - targets:
          # AlertManager not typically used in development
          # - alertmanager:9093

# ===================================================================
# Remote Write Configuration (for development data persistence)
# ===================================================================
# Uncomment if you want to send metrics to external storage
# remote_write:
#   - url: "http://prometheus-remote-write:8080/api/v1/write"
#     queue_config:
#       max_samples_per_send: 1000
#       max_shards: 200
#       capacity: 2500
