diff --git a/nixos/configuration.nix b/nixos/configuration.nix index 3e5734b..e9ddbb0 100644 --- a/nixos/configuration.nix +++ b/nixos/configuration.nix @@ -28,6 +28,7 @@ ./programs/yggdrasil.nix ./programs/grafana.nix + ./programs/prometheus.nix ]; nix = { diff --git a/nixos/programs/grafana.nix b/nixos/programs/grafana.nix index c5b3c18..3b25be2 100644 --- a/nixos/programs/grafana.nix +++ b/nixos/programs/grafana.nix @@ -16,11 +16,11 @@ }; }; - services.nginx.virtualHosts."grafana.comfycamp.space" = { + services.nginx.virtualHosts.${config.services.grafana.settings.server.domain} = { useACMEHost = "comfycamp.space"; forceSSL = true; locations."/" = { - proxyPass = "http://127.0.0.1:55010"; + proxyPass = "http://127.0.0.1:${toString config.services.grafana.settings.server.http_port}"; proxyWebsockets = true; }; }; diff --git a/nixos/programs/prometheus.nix b/nixos/programs/prometheus.nix new file mode 100644 index 0000000..0d575a5 --- /dev/null +++ b/nixos/programs/prometheus.nix @@ -0,0 +1,23 @@ +{ config, ... }: { + services.prometheus = { + enable = true; + port = 55011; + + exporters = { + node = { + enable = true; + enabledCollectors = [ "systemd" ]; + port = 55012; + }; + }; + + scrapeConfigs = [ + { + job_name = "node"; + static_configs = [{ + targets = [ "127.0.0.1:${toString config.services.prometheus.exporters.node.port}" ]; + }]; + } + ]; + }; +}