# Prometheus metrics configuration for Bridge

global:
  scrape_interval: 15s
  evaluation_interval: 15s

scrape_configs:
  - job_name: 'bridge-api'
    static_configs:
      - targets: ['localhost:8080']
    metrics_path: '/metrics'

  - job_name: 'bridge-orchestrator'
    static_configs:
      - targets: ['localhost:9090']
    metrics_path: '/metrics'

  - job_name: 'bridge-observability'
    static_configs:
      - targets: ['localhost:9091']
    metrics_path: '/metrics'

# Alert rules
groups:
  - name: bridge_alerts
    interval: 30s
    rules:
      - alert: HighFailureRate
        expr: rate(bridge_failure_count[5m]) > 0.1
        for: 5m
        annotations:
          summary: "Bridge failure rate is high"
          description: "Failure rate is {{ $value }} failures per second"

      - alert: LowSuccessRate
        expr: bridge_success_rate < 95
        for: 10m
        annotations:
          summary: "Bridge success rate is below threshold"
          description: "Success rate is {{ $value }}%"

      - alert: HighSettlementTime
        expr: bridge_avg_settlement_time > 600
        for: 15m
        annotations:
          summary: "Average settlement time is high"
          description: "Average settlement time is {{ $value }} seconds"

      - alert: LiquidityFailure
        expr: increase(bridge_liquidity_failures[1h]) > 5
        for: 5m
        annotations:
          summary: "Multiple liquidity failures detected"
          description: "{{ $value }} liquidity failures in the last hour"

      - alert: BridgePaused
        expr: bridge_paused == 1
        for: 1m
        annotations:
          summary: "Bridge is paused"
          description: "Bridge operations have been paused"
