From bdee5b86194b67b93557e6ef0c28ebb221ab36a3 Mon Sep 17 00:00:00 2001 From: notohh Date: Mon, 19 Jun 2023 09:23:56 -0400 Subject: [PATCH] hosts: init prometheus on hosts --- hosts/arashi/services/default.nix | 1 + hosts/arashi/services/prometheus.nix | 24 ++++++++++++++++++++++++ hosts/kariru/services/default.nix | 1 + hosts/kariru/services/prometheus.nix | 24 ++++++++++++++++++++++++ hosts/sakura/services/grafana.nix | 26 ++++++++++++++++++++++---- hosts/sakura/services/prometheus.nix | 4 ++-- hosts/yuki/services/default.nix | 1 + hosts/yuki/services/prometheus.nix | 24 ++++++++++++++++++++++++ 8 files changed, 99 insertions(+), 6 deletions(-) create mode 100644 hosts/arashi/services/prometheus.nix create mode 100644 hosts/kariru/services/prometheus.nix create mode 100644 hosts/yuki/services/prometheus.nix diff --git a/hosts/arashi/services/default.nix b/hosts/arashi/services/default.nix index f3c8b4a..a574ade 100644 --- a/hosts/arashi/services/default.nix +++ b/hosts/arashi/services/default.nix @@ -2,5 +2,6 @@ _: { imports = [ ./postgresql.nix ./redis.nix + ./prometheus.nix ]; } diff --git a/hosts/arashi/services/prometheus.nix b/hosts/arashi/services/prometheus.nix new file mode 100644 index 0000000..928d912 --- /dev/null +++ b/hosts/arashi/services/prometheus.nix @@ -0,0 +1,24 @@ +_: { + networking.firewall.allowedTCPPorts = [9090]; + services.prometheus = { + enable = true; + scrapeConfigs = [ + { + job_name = "prometheus"; + scrape_interval = "30s"; + static_configs = [{targets = ["localhost:9090"];}]; + } + { + job_name = "node"; + scrape_interval = "30s"; + static_configs = [{targets = ["localhost:9100"];}]; + } + ]; + exporters = { + node = { + enable = true; + enabledCollectors = ["systemd" "cpu"]; + }; + }; + }; +} diff --git a/hosts/kariru/services/default.nix b/hosts/kariru/services/default.nix index 92c06ca..7cf6424 100644 --- a/hosts/kariru/services/default.nix +++ b/hosts/kariru/services/default.nix @@ -2,6 +2,7 @@ _: { imports = [ ./traefik.nix ./torrent.nix + ./prometheus.nix ]; services.radarr = { enable = true; diff --git a/hosts/kariru/services/prometheus.nix b/hosts/kariru/services/prometheus.nix new file mode 100644 index 0000000..928d912 --- /dev/null +++ b/hosts/kariru/services/prometheus.nix @@ -0,0 +1,24 @@ +_: { + networking.firewall.allowedTCPPorts = [9090]; + services.prometheus = { + enable = true; + scrapeConfigs = [ + { + job_name = "prometheus"; + scrape_interval = "30s"; + static_configs = [{targets = ["localhost:9090"];}]; + } + { + job_name = "node"; + scrape_interval = "30s"; + static_configs = [{targets = ["localhost:9100"];}]; + } + ]; + exporters = { + node = { + enable = true; + enabledCollectors = ["systemd" "cpu"]; + }; + }; + }; +} diff --git a/hosts/sakura/services/grafana.nix b/hosts/sakura/services/grafana.nix index 7e508d4..fe542b3 100644 --- a/hosts/sakura/services/grafana.nix +++ b/hosts/sakura/services/grafana.nix @@ -14,15 +14,15 @@ _: { }; users = { allow_signup = false; - auto_assign_org = true; - auto_assign_org_role = "Viewer"; + }; + feature_toggles = { + publicDashboards = true; }; database = { type = "postgres"; host = "192.168.1.211:5432"; name = "grafana"; user = "grafana"; - password = "grafana"; ssl_mode = "disable"; }; }; @@ -32,7 +32,25 @@ _: { { name = "Prometheus"; type = "prometheus"; - url = "http://127.0.0.0:9090"; + url = "http://localhost:9090"; + orgId = 1; + } + { + name = "Prometheus-kariru"; + type = "prometheus"; + url = "http://192.168.1.54:9090"; + orgId = 1; + } + { + name = "Prometheus-yuki"; + type = "prometheus"; + url = "http://192.168.1.36:9090"; + orgId = 1; + } + { + name = "Prometheus-arashi"; + type = "prometheus"; + url = "http://192.168.1.211:9090"; orgId = 1; } ]; diff --git a/hosts/sakura/services/prometheus.nix b/hosts/sakura/services/prometheus.nix index 428b6aa..1941647 100644 --- a/hosts/sakura/services/prometheus.nix +++ b/hosts/sakura/services/prometheus.nix @@ -5,12 +5,12 @@ _: { { job_name = "prometheus"; scrape_interval = "30s"; - static_configs = [{targets = ["127.0.0.0:9090"];}]; + static_configs = [{targets = ["localhost:9090"];}]; } { job_name = "node"; scrape_interval = "30s"; - static_configs = [{targets = ["127.0.0.0:9100"];}]; + static_configs = [{targets = ["localhost:9100"];}]; } ]; exporters = { diff --git a/hosts/yuki/services/default.nix b/hosts/yuki/services/default.nix index 1a1402f..406e829 100644 --- a/hosts/yuki/services/default.nix +++ b/hosts/yuki/services/default.nix @@ -8,5 +8,6 @@ ./homarr.nix ./dashdot.nix ./miniflux.nix + ./prometheus.nix ]; } diff --git a/hosts/yuki/services/prometheus.nix b/hosts/yuki/services/prometheus.nix new file mode 100644 index 0000000..928d912 --- /dev/null +++ b/hosts/yuki/services/prometheus.nix @@ -0,0 +1,24 @@ +_: { + networking.firewall.allowedTCPPorts = [9090]; + services.prometheus = { + enable = true; + scrapeConfigs = [ + { + job_name = "prometheus"; + scrape_interval = "30s"; + static_configs = [{targets = ["localhost:9090"];}]; + } + { + job_name = "node"; + scrape_interval = "30s"; + static_configs = [{targets = ["localhost:9100"];}]; + } + ]; + exporters = { + node = { + enable = true; + enabledCollectors = ["systemd" "cpu"]; + }; + }; + }; +}