nix/nixos/common/services/telegraf.nix

78 lines
1.9 KiB
Nix
Raw Normal View History

2024-04-07 01:42:00 +02:00
{ pkgs, ... }: {
2023-07-05 12:04:30 +02:00
# Telegraf Monitoring
2023-07-06 06:23:15 +02:00
# Set up the secrets file for the token:
2023-09-19 06:49:23 +02:00
sops.secrets."services/telegraf" = {
2023-07-05 12:04:30 +02:00
owner = "telegraf";
2023-08-23 10:21:11 +02:00
sopsFile = ../../../secrets/secrets.yaml;
2023-07-05 12:04:30 +02:00
restartUnits = [ "telegraf.service" ];
};
# Install the package
environment.systemPackages = with pkgs; [
2023-07-05 12:55:15 +02:00
lm_sensors
2023-07-05 12:04:30 +02:00
telegraf
2023-07-05 14:26:30 +02:00
smartmontools
2024-01-23 06:45:04 +01:00
nvme-cli
2023-07-05 12:04:30 +02:00
];
2023-07-05 14:24:39 +02:00
# Allow telegraf to talk to other executables it requires:
2023-07-05 14:04:12 +02:00
systemd.services.telegraf = {
2023-12-10 10:54:57 +01:00
path = [
pkgs.lm_sensors # sensors
pkgs.smartmontools # smartctl
pkgs.sudo # sudo
2024-01-23 06:45:04 +01:00
pkgs.nvme-cli # nvme command for smartctl
2023-12-10 10:56:37 +01:00
"/run/current-system/sw/bin/nixos-version"
2023-07-05 14:04:12 +02:00
];
};
2023-07-05 14:03:36 +02:00
2023-07-05 12:04:30 +02:00
# Configure the package:
services.telegraf = {
enable = true;
2023-09-19 06:49:23 +02:00
environmentFiles = [ /run/secrets/services/telegraf ];
2023-07-05 12:04:30 +02:00
extraConfig = {
2023-07-05 12:47:56 +02:00
outputs = {
influxdb_v2 = {
urls = [ "https://influx.sysctl.io/" ];
2023-07-05 12:53:01 +02:00
token = "$TELEGRAF_TOKEN";
2023-07-05 12:47:56 +02:00
organization = "default";
bucket = "telegrafdb";
2023-07-05 13:45:21 +02:00
http_headers = { Authorization = "Token $TELEGRAF_TOKEN"; };
2023-07-05 12:47:56 +02:00
};
};
inputs = {
cpu = {
percpu = true;
totalcpu = true;
collect_cpu_time = false;
report_active = false;
};
2023-07-05 13:24:09 +02:00
disk = {
2023-07-05 13:30:54 +02:00
ignore_fs = ["tmpfs" "devtmpfs" "devfs" "iso9660" "overlay" "aufs" "squashfs"];
2023-07-05 13:24:09 +02:00
};
2023-07-05 12:47:56 +02:00
diskio = {};
kernel = {};
mem = {};
processes = {};
swap = {};
system = {};
net = {};
2023-08-23 16:23:14 +02:00
# nvidia_smi = {};
2023-07-05 12:47:56 +02:00
sensors = {};
smart = {
2023-07-05 12:54:39 +02:00
timeout = "30s";
2023-07-05 12:47:56 +02:00
};
temp = {};
wireless = {};
2023-12-10 10:25:00 +01:00
exec = {
2023-12-10 10:58:55 +01:00
commands = [ "/run/current-system/sw/bin/nixos-version" ];
2023-12-10 10:45:11 +01:00
name_suffix = "_nixos-version";
2023-12-10 10:25:00 +01:00
data_format = "value";
data_type = "string";
};
2023-07-05 12:47:56 +02:00
};
2023-07-05 12:04:30 +02:00
};
};
2024-04-07 01:42:00 +02:00
}