Skip to content
Snippets Groups Projects
blackbox.nix 880 B
# Prometheus blackbox exporter config
#
# Scope: From the monitoring machine, ping (etc.) hosts to check wether
#        they are reachable, certs still are valid for a while, etc.
#
# Notes: Blackbox exporter is using the "Multi Target Exporter" pattern,
#        see https://prometheus.io/docs/guides/multi-target-exporter/ .
#
# Usage: Import this on a monitoring server

{ config, lib, pkgs, ... }: {
  config.services.prometheus.exporters.blackbox = {
    enable = true;

    configFile = pkgs.writeText "blackbox-exporter.yaml" (builtins.toJSON {
      modules = {
        https_2xx = {
          prober = "http";
          timeout = "5s";
          http = {
            fail_if_not_ssl = true;
            # This prober is for IPv4 only.
            preferred_ip_protocol = "ip4";
            ip_protocol_fallback = false;
          };
        };
      };
    });

  };
}