global:
  scrape_interval: 15s
  evaluation_interval: 15s
  external_labels:
    cluster: 'the-order'
    environment: 'production'

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

  # Intake Service
  - job_name: 'intake-service'
    kubernetes_sd_configs:
      - role: pod
        namespaces:
          names:
            - the-order
    relabel_configs:
      - source_labels: [__meta_kubernetes_pod_label_app]
        action: keep
        regex: intake-service
      - source_labels: [__meta_kubernetes_pod_ip]
        action: replace
        target_label: __address__
        replacement: $1:4001
      - action: labelmap
        regex: __meta_kubernetes_pod_label_(.+)
    metrics_path: '/metrics'

  # Identity Service
  - job_name: 'identity-service'
    kubernetes_sd_configs:
      - role: pod
        namespaces:
          names:
            - the-order
    relabel_configs:
      - source_labels: [__meta_kubernetes_pod_label_app]
        action: keep
        regex: identity-service
      - source_labels: [__meta_kubernetes_pod_ip]
        action: replace
        target_label: __address__
        replacement: $1:4002
      - action: labelmap
        regex: __meta_kubernetes_pod_label_(.+)
    metrics_path: '/metrics'

  # Finance Service
  - job_name: 'finance-service'
    kubernetes_sd_configs:
      - role: pod
        namespaces:
          names:
            - the-order
    relabel_configs:
      - source_labels: [__meta_kubernetes_pod_label_app]
        action: keep
        regex: finance-service
      - source_labels: [__meta_kubernetes_pod_ip]
        action: replace
        target_label: __address__
        replacement: $1:4003
      - action: labelmap
        regex: __meta_kubernetes_pod_label_(.+)
    metrics_path: '/metrics'

  # Dataroom Service
  - job_name: 'dataroom-service'
    kubernetes_sd_configs:
      - role: pod
        namespaces:
          names:
            - the-order
    relabel_configs:
      - source_labels: [__meta_kubernetes_pod_label_app]
        action: keep
        regex: dataroom-service
      - source_labels: [__meta_kubernetes_pod_ip]
        action: replace
        target_label: __address__
        replacement: $1:4004
      - action: labelmap
        regex: __meta_kubernetes_pod_label_(.+)
    metrics_path: '/metrics'

  # Legal Documents Service
  - job_name: 'legal-documents-service'
    kubernetes_sd_configs:
      - role: pod
        namespaces:
          names:
            - the-order
    relabel_configs:
      - source_labels: [__meta_kubernetes_pod_label_app]
        action: keep
        regex: legal-documents-service
      - source_labels: [__meta_kubernetes_pod_ip]
        action: replace
        target_label: __address__
        replacement: $1:4005
      - action: labelmap
        regex: __meta_kubernetes_pod_label_(.+)
    metrics_path: '/metrics'

  # Kubernetes API
  - job_name: 'kubernetes-apiservers'
    kubernetes_sd_configs:
      - role: endpoints
    scheme: https
    tls_config:
      ca_file: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
    bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
    relabel_configs:
      - source_labels: [__meta_kubernetes_namespace, __meta_kubernetes_service_name, __meta_kubernetes_endpoint_port_name]
        action: keep
        regex: default;kubernetes;https

  # Kubernetes nodes
  - job_name: 'kubernetes-nodes'
    kubernetes_sd_configs:
      - role: node
    scheme: https
    tls_config:
      ca_file: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
    bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
    relabel_configs:
      - action: labelmap
        regex: __meta_kubernetes_node_label_(.+)

alerting:
  alertmanagers:
    - static_configs:
        - targets:
          - alertmanager:9093

rule_files:
  - '/etc/prometheus/alert-rules.yml'

