From ba615f1b29c21ec594f5bb3c16bfd4be5916dc7d Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Thu, 13 Apr 2023 23:50:21 +0200 Subject: [PATCH] service/prometheus: enable systemd target and make datasource default --- modules/services/prometheus/default.nix | 30 ++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/modules/services/prometheus/default.nix b/modules/services/prometheus/default.nix index 9889566..bd2ef35 100644 --- a/modules/services/prometheus/default.nix +++ b/modules/services/prometheus/default.nix @@ -45,6 +45,10 @@ in port = 9100; listenAddress = "127.0.0.1"; }; + systemd = { + enable = true; + listenAddress = "127.0.0.1"; + }; }; globalConfig = { @@ -53,9 +57,30 @@ in scrapeConfigs = [ { - job_name = config.networking.hostName; + job_name = "prometheus"; + static_configs = [{ + targets = [ "127.0.0.1:${toString cfg.port}" ]; + labels = { + instance = config.networking.hostName; + }; + }]; + } + { + job_name = "node"; static_configs = [{ targets = [ "127.0.0.1:${toString config.services.prometheus.exporters.node.port}" ]; + labels = { + instance = config.networking.hostName; + }; + }]; + } + { + job_name = "systemd"; + static_configs = [{ + targets = [ "127.0.0.1:${toString config.services.prometheus.exporters.systemd.port}" ]; + labels = { + instance = config.networking.hostName; + }; }]; } ]; @@ -66,8 +91,11 @@ in { name = "Prometheus"; type = "prometheus"; + isDefault = true; url = "http://127.0.0.1:${toString config.services.prometheus.port}"; jsonData = { + prometheusType = "Prometheus"; + prometheusVersion = toString pkgs.prometheus.version; timeInterval = config.services.prometheus.globalConfig.scrape_interval; }; }