# Prometheus Configuration for Synor Testnet Monitoring
# 30-day retention configured in docker-compose

global:
  scrape_interval: 15s
  evaluation_interval: 15s
  external_labels:
    cluster: 'synor-testnet'
    environment: 'testnet'

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

# Load alert rules
rule_files:
  - /etc/prometheus/alerts.yml

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

  # ==========================================================================
  # Synor Seed Nodes
  # ==========================================================================
  - job_name: 'synor-nodes'
    scrape_interval: 10s
    static_configs:
      - targets:
          - 'seed1:17110'  # Seed 1 RPC (metrics endpoint assumed at /metrics)
          - 'seed2:17110'  # Seed 2
          - 'seed3:17110'  # Seed 3
        labels:
          network: 'testnet'
    metrics_path: /metrics
    # If no /metrics endpoint, use blackbox exporter pattern below

  # ==========================================================================
  # Synor Node Health Checks (via HTTP probe)
  # ==========================================================================
  - job_name: 'synor-health'
    scrape_interval: 30s
    metrics_path: /probe
    params:
      module: [http_2xx]
    static_configs:
      - targets:
          - 'http://seed1:17110/health'
          - 'http://seed2:17110/health'
          - 'http://seed3:17110/health'
        labels:
          network: 'testnet'
    relabel_configs:
      - source_labels: [__address__]
        target_label: __param_target
      - source_labels: [__param_target]
        target_label: instance
      - target_label: __address__
        replacement: blackbox-exporter:9115  # If using blackbox exporter

  # ==========================================================================
  # RPC Endpoint Monitoring (custom metrics via script)
  # ==========================================================================
  - job_name: 'synor-rpc-stats'
    scrape_interval: 30s
    static_configs:
      - targets:
          - 'seed1:17110'
          - 'seed2:17110'
          - 'seed3:17110'
    metrics_path: /api/v1/stats
    # Note: This assumes the /stats endpoint returns Prometheus-compatible format
    # If not, we'll use a custom exporter

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

  # ==========================================================================
  # Explorer API
  # ==========================================================================
  - job_name: 'explorer-api'
    static_configs:
      - targets: ['explorer-api:3000']
        labels:
          service: 'explorer'
    metrics_path: /health
