Add prometheus monitoring

This commit is contained in:
Torjus Håkestad 2024-06-03 03:44:34 +02:00
parent ae3841ae09
commit 2576748c38
2 changed files with 34 additions and 0 deletions

View File

@ -3,5 +3,6 @@
./sops.nix ./sops.nix
./root-user.nix ./root-user.nix
./sshd.nix ./sshd.nix
./monitoring.nix
]; ];
} }

33
system/monitoring.nix Normal file
View File

@ -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 ];
}