From 3a4628aef94f09353cd3c88c005cf6d45a2dafe0 Mon Sep 17 00:00:00 2001 From: notohh Date: Tue, 17 Oct 2023 02:45:11 -0400 Subject: [PATCH] modules: move prometheus to dedicated folder --- modules/README.md | 1 + modules/default.nix | 2 +- .../{prometheus.nix => prometheus/default.nix} | 16 +++++++++++++--- modules/prometheus/exporters/postgres.nix | 7 +++++++ modules/prometheus/exporters/redis.nix | 7 +++++++ 5 files changed, 29 insertions(+), 4 deletions(-) rename modules/{prometheus.nix => prometheus/default.nix} (59%) create mode 100644 modules/prometheus/exporters/postgres.nix create mode 100644 modules/prometheus/exporters/redis.nix diff --git a/modules/README.md b/modules/README.md index 8f37655..466a5df 100644 --- a/modules/README.md +++ b/modules/README.md @@ -4,6 +4,7 @@ this directory hosts some common modules / services / security tweaks used on (m name | description --------------- | ----------- +`prometheus` | has default prometheus config for all hosts, along with exporters for select hosts `default` | used for commonly shared modules `fonts` | font handling `greetd` | login manager diff --git a/modules/default.nix b/modules/default.nix index 5c8b421..c7048be 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -1,6 +1,7 @@ {inputs, ...}: { imports = [ inputs.nh.nixosModules.default + ./prometheus ./security.nix ./networking.nix ./users.nix @@ -9,6 +10,5 @@ ./openssh.nix ./virtualisation.nix ./sops.nix - ./prometheus.nix ]; } diff --git a/modules/prometheus.nix b/modules/prometheus/default.nix similarity index 59% rename from modules/prometheus.nix rename to modules/prometheus/default.nix index 51ee113..9d86e41 100644 --- a/modules/prometheus.nix +++ b/modules/prometheus/default.nix @@ -5,19 +5,29 @@ _: { scrapeConfigs = [ { job_name = "prometheus"; - scrape_interval = "30s"; + scrape_interval = "15s"; static_configs = [{targets = ["localhost:9090"];}]; } { job_name = "node"; - scrape_interval = "30s"; + scrape_interval = "15s"; static_configs = [{targets = ["localhost:9100"];}]; } { job_name = "traefik"; - scrape_interval = "30s"; + scrape_interval = "15s"; static_configs = [{targets = ["100.87.54.48:8080"];}]; } + { + job_name = "redis_exporter"; + scrape_interval = "15s"; + static_configs = [{targets = ["100.94.214.100:9002"];}]; + } + { + job_name = "postgres"; + scrape_interval = "15s"; + static_configs = [{targets = ["100.94.214.100:9003"];}]; + } ]; exporters = { node = { diff --git a/modules/prometheus/exporters/postgres.nix b/modules/prometheus/exporters/postgres.nix new file mode 100644 index 0000000..a1ffc5a --- /dev/null +++ b/modules/prometheus/exporters/postgres.nix @@ -0,0 +1,7 @@ +_: { + services.prometheus.exporters.postgres = { + enable = true; + openFirewall = true; + port = 9003; + }; +} \ No newline at end of file diff --git a/modules/prometheus/exporters/redis.nix b/modules/prometheus/exporters/redis.nix new file mode 100644 index 0000000..4e03ff9 --- /dev/null +++ b/modules/prometheus/exporters/redis.nix @@ -0,0 +1,7 @@ +_: { + services.prometheus.exporters.redis = { + enable = true; + openFirewall = true; + port = 9002; + }; +}