From 5bd1d673334b96e63ac2a9a5d01ef6ef43e36f5e Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Mallo Date: Tue, 29 Aug 2023 11:53:32 +0200 Subject: [PATCH] Add monitoring in the bay node --- m/bay/configuration.nix | 1 + m/bay/monitoring.nix | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 m/bay/monitoring.nix diff --git a/m/bay/configuration.nix b/m/bay/configuration.nix index 41d0a56..6aff18e 100644 --- a/m/bay/configuration.nix +++ b/m/bay/configuration.nix @@ -3,6 +3,7 @@ { imports = [ ../common/main.nix + ./monitoring.nix ]; # Select the this using the ID to avoid mismatches diff --git a/m/bay/monitoring.nix b/m/bay/monitoring.nix new file mode 100644 index 0000000..0ef9209 --- /dev/null +++ b/m/bay/monitoring.nix @@ -0,0 +1,25 @@ +{ config, lib, ... }: + +{ + # We need access to the devices to monitor the disk space + systemd.services.prometheus-node-exporter.serviceConfig.PrivateDevices = lib.mkForce false; + systemd.services.prometheus-node-exporter.serviceConfig.ProtectHome = lib.mkForce "read-only"; + + # Required to allow the smartctl exporter to read the nvme0 character device, + # see the commit message on: + # https://github.com/NixOS/nixpkgs/commit/12c26aca1fd55ab99f831bedc865a626eee39f80 + services.udev.extraRules = '' + SUBSYSTEM=="nvme", KERNEL=="nvme[0-9]*", GROUP="disk" + ''; + + services.prometheus = { + exporters = { + node = { + enable = true; + enabledCollectors = [ "systemd" ]; + port = 9002; + }; + smartctl.enable = true; + }; + }; +}