diff --git a/hosts/sakura/services/default.nix b/hosts/sakura/services/default.nix index e32b7ba..e8762d7 100644 --- a/hosts/sakura/services/default.nix +++ b/hosts/sakura/services/default.nix @@ -9,5 +9,7 @@ ./forgejo.nix ./jellyfin.nix ./rustypaste.nix + ./grafana.nix + ./prometheus.nix ]; } diff --git a/hosts/sakura/services/grafana.nix b/hosts/sakura/services/grafana.nix new file mode 100644 index 0000000..6e095b3 --- /dev/null +++ b/hosts/sakura/services/grafana.nix @@ -0,0 +1,34 @@ +{...}: { + services.grafana = { + enable = true; + settings = { + server = { + root_url = "https://metrics.notohh.dev"; + domain = "metrics.notohh.dev"; + enforce_domain = true; + http_addr = "0.0.0.0"; + http_port = 3100; + }; + auth = { + disable_login_form = false; + }; + users = { + allow_signup = false; + auto_assign_org = true; + auto_assign_org_role = "Viewer"; + }; + }; + provision = { + datasources.settings = { + datasources = [ + { + name = "Prometheus"; + type = "prometheus"; + url = "http://127.0.0.0:9090"; + orgId = 1; + } + ]; + }; + }; + }; +} diff --git a/hosts/sakura/services/prometheus.nix b/hosts/sakura/services/prometheus.nix new file mode 100644 index 0000000..f5e70c9 --- /dev/null +++ b/hosts/sakura/services/prometheus.nix @@ -0,0 +1,23 @@ +{...}: { + services.prometheus = { + enable = true; + scrapeConfigs = [ + { + job_name = "prometheus"; + scrape_interval = "30s"; + static_configs = [{targets = ["127.0.0.0:9090"];}]; + } + { + job_name = "node"; + scrape_interval = "30s"; + static_configs = [{targets = ["127.0.0.0:9100"];}]; + } + ]; + exporters = { + node = { + enable = true; + enabledCollectors = ["systemd" "cpu"]; + }; + }; + }; +} diff --git a/hosts/sakura/services/traefik.nix b/hosts/sakura/services/traefik.nix index 58ac533..471abc8 100644 --- a/hosts/sakura/services/traefik.nix +++ b/hosts/sakura/services/traefik.nix @@ -68,6 +68,13 @@ tls.domains = [{main = "*.notohh.dev";}]; tls.certresolver = "production"; }; + grafana = { + rule = "Host(`metrics.notohh.dev`)"; + entrypoints = ["websecure"]; + service = "grafana"; + tls.domains = [{main = "*.notohh.dev";}]; + tls.certresolver = "production"; + }; }; services = { homepage.loadBalancer.servers = [{url = "http://localhost:3005";}]; @@ -78,6 +85,7 @@ foundryvtt.loadBalancer.servers = [{url = "http://localhost:30000";}]; gitea.loadBalancer.servers = [{url = "http://localhost:3000";}]; rustypaste.loadBalancer.servers = [{url = "http://localhost:8000";}]; + grafana.loadBalancer.servers = [{url = "http://localhost:3100";}]; }; }; };