stacks/monitoring/prometheus/prometheus.yml

# stacks/monitoring/prometheus/prometheus.yml
# Canonical scrape config for the homelab. Keep jobs alphabetized.
# See mercemay.top/src/homelab-compose/ for the companion alert rules.

global:
  scrape_interval: 30s
  scrape_timeout: 10s
  evaluation_interval: 30s
  external_labels:
    origin: homelab
    region: home-arpa

rule_files:
  - /etc/prometheus/rules/recording.yml
  - /etc/prometheus/rules/alerts.yml
  - /etc/prometheus/rules/blackbox.yml

alerting:
  alertmanagers:
    - static_configs:
        - targets: ["alertmanager:9093"]
      timeout: 5s

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

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

  - job_name: node
    static_configs:
      - targets: ["node-exporter:9100"]
        labels:
          host: homelab-1
          role: metal

  - job_name: cadvisor
    static_configs:
      - targets: ["cadvisor:8080"]
    metric_relabel_configs:
      - source_labels: [__name__]
        regex: "container_(fs_inodes_free|tasks_state|memory_failcnt)"
        action: drop
      - source_labels: [container_label_com_docker_compose_service]
        target_label: service

  - job_name: caddy
    metrics_path: /metrics
    static_configs:
      - targets: ["caddy:2019"]

  - job_name: loki
    metrics_path: /metrics
    static_configs:
      - targets: ["loki:3100"]

  - job_name: grafana
    metrics_path: /metrics
    static_configs:
      - targets: ["grafana:3000"]

  - job_name: blackbox_http
    metrics_path: /probe
    params:
      module: [http_2xx]
    static_configs:
      - targets:
          - https://jellyfin.home.arpa
          - https://gitea.home.arpa
          - https://immich.home.arpa
          - https://paperless.home.arpa
          - https://grafana.home.arpa
    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_tcp
    metrics_path: /probe
    params:
      module: [tcp_connect]
    static_configs:
      - targets:
          - postgres:5432
          - redis:6379
    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: smart
    static_configs:
      - targets: ["node-exporter:9100"]
    metrics_path: /metrics
    honor_labels: true
    params:
      collect[]: [textfile]