global:
  scrape_interval: 15s
  evaluation_interval: 15s

# Link the rules
rule_files:
  - "alert.rules.yml"

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

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

  # node-exporter runs on the host network, so we use 'host.containers.internal' to access it from the container.
  - job_name: 'node-exporter'
    static_configs:
      - targets: ['host.containers.internal:9100']

  - job_name: 'podman-exporter'
    static_configs:
      - targets: ['podman-exporter:9882']

  - job_name: 'alertmanager'
    static_configs:
      - targets: ['alertmanager:9093']

  - job_name: 'grafana'
    static_configs:
      - targets: ['grafana:3000']

  - job_name: 'loki'
    static_configs:
      - targets: ['loki:3100']

  - job_name: 'alloy'
    static_configs:
      - targets: ['alloy:12345']

  - job_name: 'karma'
    static_configs:
      - targets: ['karma:8080']

  # HTTP probes for the different services. We use the blackbox exporter to perform these probes.
  - job_name: 'blackbox-http'
    metrics_path: /probe
    params:
      module: [http_2xx]
    static_configs:
      - targets:
        # Alertmanager
        - http://alertmanager:9093/-/healthy
        # Alloy
        - http://alloy:12345/-/healthy
        # Blackbox Exporter
        - http://blackbox-exporter:9115/-/healthy
        # Karma
        - http://karma:8080/health
        # Grafana
        - http://grafana:3000/healthz
        # Loki
        - http://loki:3100/ready
        # MinIO
        - http://minio:9000/minio/health/ready
        # Note: runs on host network!
        - http://host.containers.internal:9100
        # NGINX
        - http://nginx:80/
        # OTel Collector
        - http://otel-collector:8888/metrics
        # Podman Exporter
        - http://podman-exporter:9882
        # Prometheus
        - http://prometheus:9090/-/healthy
        # Pyroscope
        - http://pyroscope:4040/ready
        # tempo
        - http://tempo:3200/ready
        # Traefik
        - http://traefik:8082/ping
        # webhook-tester
        - http://webhook-tester:8080/
    relabel_configs:
      - source_labels: [__address__]
        target_label: __param_target
      - source_labels: [__param_target]
        target_label: instance
      - target_label: __address__
        replacement: blackbox-exporter:9115

  # Keep API HTTP probe with custom header
  - job_name: 'blackbox-keep-api'
    metrics_path: /probe
    params:
      module: [http_keep_api]
    static_configs:
      - targets:
        - http://keep-backend:8080/metrics/processing
    relabel_configs:
      - source_labels: [__address__]
        target_label: __param_target
      - source_labels: [__param_target]
        target_label: instance
      - target_label: __address__
        replacement: blackbox-exporter:9115

  # Keep Frontend HTTP probe
  - job_name: 'blackbox-keep-ui'
    metrics_path: /probe
    params:
      module: [http_keep_ui]
    static_configs:
      - targets:
        - http://keep-frontend:3000/api/healthcheck
    relabel_configs:
      - source_labels: [__address__]
        target_label: __param_target
      - source_labels: [__param_target]
        target_label: instance
      - target_label: __address__
        replacement: blackbox-exporter:9115

  # TCP probe Postgres Database
  - job_name: 'blackbox-tcp'
    metrics_path: /probe
    params:
      module: [tcp_connect]
    static_configs:
      - targets:
        - keep-db:5432
    relabel_configs:
      - source_labels: [__address__]
        target_label: __param_target
      - source_labels: [__param_target]
        target_label: instance
      - target_label: __address__
        replacement: blackbox-exporter:9115

  - job_name: 'blackbox_exporter'
    static_configs:
      - targets: ['blackbox-exporter:9115']

  - job_name: 'tempo'
    static_configs:
      - targets: ['tempo:3200']

  - job_name: 'otel-collector'
    static_configs:
      - targets: ['otel-collector:8888']

  # MinIO has different metrics endpoints, so we define multiple jobs for each metric type.
  - job_name: 'minio-job'
    metrics_path: /minio/v2/metrics/cluster
    scheme: http
    static_configs:
      - targets: ['minio:9000']
  - job_name: minio-job-bucket
    metrics_path: /minio/v2/metrics/bucket
    static_configs:
    - targets: ['minio:9000']
  - job_name: minio-job-node
    metrics_path: /minio/v2/metrics/node
    static_configs:
    - targets: ['minio:9000']
  - job_name: minio-job-resource
    metrics_path: /minio/v2/metrics/resource
    static_configs:
    - targets: ['minio:9000']

  - job_name: 'traefik'
    static_configs:
      - targets: ['traefik:8082']

  - job_name: "keep"
    static_configs:
      - targets: ["keep-backend:8080"]
    metrics_path: "/metrics/processing"
    http_headers:
      x-api-key:
        values:
          - "585af6cc-5c07-427f-966f-a263473ad402"

  - job_name: 'pyroscope'
    static_configs:
      - targets: ['pyroscope:4040']
