diff --git a/system/default.nix b/system/default.nix index 06aee46..debf8f0 100644 --- a/system/default.nix +++ b/system/default.nix @@ -3,5 +3,6 @@ ./sops.nix ./root-user.nix ./sshd.nix + ./monitoring.nix ]; } diff --git a/system/monitoring.nix b/system/monitoring.nix new file mode 100644 index 0000000..312489e --- /dev/null +++ b/system/monitoring.nix @@ -0,0 +1,33 @@ +{ pkgs, ... }: +{ + environment.systemPackages = with pkgs; [ + prometheus-node-exporter + prometheus-systemd-exporter + ]; + + systemd.services."node-exporter" = { + enable = true; + unitConfig = { + Description = "Prometheus Node Exporter"; + After = [ "network.target" ]; + }; + serviceConfig = { + ExecStart = "${pkgs.prometheus-node-exporter}/bin/node_exporter"; + }; + wantedBy = [ "multi-user.target" ]; + }; + + systemd.services."systemd-exporter" = { + enable = true; + unitConfig = { + Description = "Prometheus Systemd Exporter"; + After = [ "network.target" ]; + }; + serviceConfig = { + ExecStart = "${pkgs.prometheus-systemd-exporter}/bin/systemd_exporter"; + }; + wantedBy = [ "multi-user.target" ]; + }; + + networking.firewall.allowedTCPPorts = [ 9100 9558 8989 ]; +}