From 37ea31b0853301893fd0d34d53ea80f0cf36217a Mon Sep 17 00:00:00 2001 From: niten Date: Sat, 27 Jul 2024 18:29:00 -0700 Subject: [PATCH] Better default for scraper port --- lib/fudo/prometheus.nix | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/lib/fudo/prometheus.nix b/lib/fudo/prometheus.nix index 2bf358c..6c0157f 100644 --- a/lib/fudo/prometheus.nix +++ b/lib/fudo/prometheus.nix @@ -37,10 +37,14 @@ in { port = mkOption { type = port; description = "Port on which to scrape for metrics."; - default = 80; + default = + if toplevel.config.fudo.metrics.prometheus.private-network then + 80 + else + 443; }; - hostnames = mkOption { + static-targets = mkOption { type = listOf str; description = "Explicit list of hosts to scrape for metrics."; default = [ ]; @@ -144,16 +148,17 @@ in { port = 9090; scrapeConfigs = let - mkScraper = { name, secured, path, port, hostnames, dns-sd-records }: { - job_name = name; - honor_labels = false; - scheme = if secured then "https" else "http"; - metrics_path = path; - static_configs = - let attachPort = hostname: "${hostname}:${toString port}"; - in [{ targets = map attachPort hostnames; }]; - dns_sd_configs = [{ names = dns-sd-records; }]; - }; + mkScraper = + { name, secured, path, port, static-targets, dns-sd-records }: { + job_name = name; + honor_labels = false; + scheme = if secured then "https" else "http"; + metrics_path = path; + static_configs = + let attachPort = target: "${target}:${toString port}"; + in [{ targets = map attachPort static-targets; }]; + dns_sd_configs = [{ names = dns-sd-records; }]; + }; in map mkScraper cfg.scrapers; pushgateway = {