global:
  scrape_interval: 15s
  evaluation_interval: 15s
  external_labels:
    cluster: 'defi-oracle-mainnet'
    environment: 'production'

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

# Load rules
rule_files:
  - "alerts/*.yml"

# Scrape configurations
scrape_configs:
  # Prometheus itself
  - job_name: 'prometheus'
    static_configs:
      - targets: ['localhost:9090']

  # Besu validators
  - job_name: 'besu-validators'
    kubernetes_sd_configs:
      - role: pod
        namespaces:
          names:
            - besu-network
    relabel_configs:
      - source_labels: [__meta_kubernetes_pod_label_component]
        action: keep
        regex: validator
      - source_labels: [__meta_kubernetes_pod_ip]
        action: replace
        target_label: __address__
        replacement: $1:9545
      - source_labels: [__meta_kubernetes_pod_name]
        target_label: instance

  # Besu sentries
  - job_name: 'besu-sentries'
    kubernetes_sd_configs:
      - role: pod
        namespaces:
          names:
            - besu-network
    relabel_configs:
      - source_labels: [__meta_kubernetes_pod_label_component]
        action: keep
        regex: sentry
      - source_labels: [__meta_kubernetes_pod_ip]
        action: replace
        target_label: __address__
        replacement: $1:9545
      - source_labels: [__meta_kubernetes_pod_name]
        target_label: instance

  # Besu RPC nodes
  - job_name: 'besu-rpc'
    kubernetes_sd_configs:
      - role: pod
        namespaces:
          names:
            - besu-network
    relabel_configs:
      - source_labels: [__meta_kubernetes_pod_label_component]
        action: keep
        regex: rpc
      - source_labels: [__meta_kubernetes_pod_ip]
        action: replace
        target_label: __address__
        replacement: $1:9545
      - source_labels: [__meta_kubernetes_pod_name]
        target_label: instance

  # Oracle publisher
  - job_name: 'oracle-publisher'
    kubernetes_sd_configs:
      - role: pod
        namespaces:
          names:
            - besu-network
    relabel_configs:
      - source_labels: [__meta_kubernetes_pod_label_app]
        action: keep
        regex: oracle-publisher
      - source_labels: [__meta_kubernetes_pod_ip]
        action: replace
        target_label: __address__
        replacement: $1:8000
      - source_labels: [__meta_kubernetes_pod_name]
        target_label: instance

  # CCIP monitor
  - job_name: 'ccip-monitor'
    kubernetes_sd_configs:
      - role: pod
        namespaces:
          names:
            - besu-network
    relabel_configs:
      - source_labels: [__meta_kubernetes_pod_label_app]
        action: keep
        regex: ccip-monitor
      - source_labels: [__meta_kubernetes_pod_ip]
        action: replace
        target_label: __address__
        replacement: $1:8000
      - source_labels: [__meta_kubernetes_pod_name]
        target_label: instance

  # Kubernetes nodes
  - job_name: 'kubernetes-nodes'
    kubernetes_sd_configs:
      - role: node
    relabel_configs:
      - action: labelmap
        regex: __meta_kubernetes_node_label_(.+)

  # Kubernetes pods
  - job_name: 'kubernetes-pods'
    kubernetes_sd_configs:
      - role: pod
    relabel_configs:
      - action: labelmap
        regex: __meta_kubernetes_pod_label_(.+)
      - source_labels: [__meta_kubernetes_namespace]
        action: replace
        target_label: kubernetes_namespace
      - source_labels: [__meta_kubernetes_pod_name]
        action: replace
        target_label: kubernetes_pod_name

