1
1
Fork 1
mirror of https://github.com/oddlama/nix-config.git synced 2025-10-10 23:00:39 +02:00

fix: properly pass influx token to telegraf

This commit is contained in:
oddlama 2023-08-17 10:51:47 +02:00
parent ad0164c787
commit 301e7b353c
No known key found for this signature in database
GPG key ID: 14EFE510775FE39A
2 changed files with 8 additions and 6 deletions

View file

@ -182,8 +182,6 @@ kanidm group add-members grafana-server-admins myuser
kanidm group add-members web-sentinel-access myuser
kanidm group add-members web-sentinel-adguardhome-access myuser
kanidm group add-members web-sentinel-influxdb-access myuser
# TODO influxdb temporary pw d0lRidLSqZ03W5BBjQ7Id3oM2zVE5jLrRUKcMXeYDk5WGabb
```

View file

@ -106,7 +106,7 @@ in {
services.telegraf = {
enable = true;
environmentFiles = ["/run/telegraf/env"];
environmentFiles = ["/dev/null"]; # Needed so the config file is copied to /run/telegraf
extraConfig = {
agent = {
interval = "10s";
@ -188,10 +188,14 @@ in {
(mkIf cfg.scrapeSensors
(pkgs.writeShellScriptBin "sensors" config.security.elewrap.telegraf-sensors.path))
];
preStart = mkAfter ''
echo "INFLUX_TOKEN=$(< ${config.age.secrets.telegraf-influxdb-token.path})" > /run/telegraf/env
'';
serviceConfig = {
Environment = "INFLUX_TOKEN=\$INFLUX_TOKEN"; # Required so the first envsubst in the original module doesn't change it
ExecStartPre = mkAfter [
(pkgs.writeShellScript "pre-start-token" ''
export INFLUX_TOKEN=$(< ${config.age.secrets.telegraf-influxdb-token.path})
${pkgs.envsubst}/bin/envsubst -i /var/run/telegraf/config.toml -o /var/run/telegraf/config.toml
'')
];
# For wireguard statistics
AmbientCapabilities = ["CAP_NET_ADMIN"];
RestartSec = "600"; # Retry every 10 minutes