Skip to content

Commit

Permalink
prometheus-node-exporter: fix log permissions
Browse files Browse the repository at this point in the history
The daemon won’t start as the assigned user doesn’t have
permissions to create the log file.
  • Loading branch information
emilazy committed Nov 5, 2024
1 parent 2f05a81 commit 84d14d4
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions modules/services/monitoring/prometheus-node-exporter.nix
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ in {
users.users._prometheus-node-exporter = {
uid = config.ids.uids._prometheus-node-exporter;
gid = config.ids.gids._prometheus-node-exporter;
home = "/var/empty";
home = "/var/lib/prometheus-node-exporter";
createHome = true;
shell = "/usr/bin/false";
description = "System user for the Prometheus Node exporter";
};
Expand All @@ -104,11 +105,14 @@ in {
++ (map (collector: "--collector.${collector}") cfg.enabledCollectors)
++ (map (collector: "--no-collector.${collector}") cfg.disabledCollectors)
) + escapeShellArgs cfg.extraFlags;
serviceConfig = {
serviceConfig = let
logPath = config.users.users._prometheus-node-exporter.home
+ "/prometheus-node-exporter.log";
in {
KeepAlive = true;
RunAtLoad = true;
StandardErrorPath = "/var/log/prometheus-node-exporter.log";
StandardOutPath = "/var/log/prometheus-node-exporter.log";
StandardErrorPath = logPath;
StandardOutPath = logPath;
GroupName = "_prometheus-node-exporter";
UserName = "_prometheus-node-exporter";
};
Expand Down

0 comments on commit 84d14d4

Please sign in to comment.