nix/nixos/common/services/telegraf.nix
2024-01-23 14:45:04 +09:00

77 lines
No EOL
2 KiB
Nix

{ config, pkgs, hostname, ... }: {
# Telegraf Monitoring
# Set up the secrets file for the token:
sops.secrets."services/telegraf" = {
owner = "telegraf";
sopsFile = ../../../secrets/secrets.yaml;
restartUnits = [ "telegraf.service" ];
};
# Install the package
environment.systemPackages = with pkgs; [
lm_sensors
telegraf
smartmontools
nvme-cli
];
# Allow telegraf to talk to other executables it requires:
systemd.services.telegraf = {
path = [
pkgs.lm_sensors # sensors
pkgs.smartmontools # smartctl
pkgs.sudo # sudo
pkgs.nvme-cli # nvme command for smartctl
"/run/current-system/sw/bin/nixos-version"
];
};
# Configure the package:
services.telegraf = {
enable = true;
environmentFiles = [ /run/secrets/services/telegraf ];
extraConfig = {
outputs = {
influxdb_v2 = {
urls = [ "https://influx.sysctl.io/" ];
token = "$TELEGRAF_TOKEN";
organization = "default";
bucket = "telegrafdb";
http_headers = { Authorization = "Token $TELEGRAF_TOKEN"; };
};
};
inputs = {
cpu = {
percpu = true;
totalcpu = true;
collect_cpu_time = false;
report_active = false;
};
disk = {
ignore_fs = ["tmpfs" "devtmpfs" "devfs" "iso9660" "overlay" "aufs" "squashfs"];
};
diskio = {};
kernel = {};
mem = {};
processes = {};
swap = {};
system = {};
net = {};
# nvidia_smi = {};
sensors = {};
smart = {
timeout = "30s";
};
temp = {};
wireless = {};
exec = {
commands = [ "/run/current-system/sw/bin/nixos-version" ];
name_suffix = "_nixos-version";
data_format = "value";
data_type = "string";
};
};
};
};
}