Replace three custom Prometheus textfile collector scripts with
dedicated community-maintained exporters:
- jellyfin-collector.nix (25 LoC shell) -> rebelcore/jellyfin_exporter
Metric: jellyfin_active_streams -> count(jellyfin_now_playing_state)
Bonus: per-session labels (user, title, device, codec info)
- qbittorrent-collector.nix (40 LoC shell) -> anriha/qbittorrent-metrics-exporter
Metric: qbittorrent_{download,upload}_bytes_per_second -> qbit_{dl,up}speed
Bonus: per-torrent metrics with category/tag aggregation
- intel-gpu-collector.nix + .py (130 LoC Python) -> mike1808/igpu-exporter
Metric: intel_gpu_engine_busy_percent -> igpu_engines_busy_percent
Bonus: persistent daemon vs oneshot timer, no streaming JSON parser
All three run as persistent daemons scraped by Prometheus, replacing
the textfile-collector pattern of systemd timers writing .prom files.
Dashboard PromQL queries updated to match new metric names.
99 lines
2.5 KiB
Nix
99 lines
2.5 KiB
Nix
{
|
|
service_configs,
|
|
lib,
|
|
...
|
|
}:
|
|
let
|
|
textfileDir = "/var/lib/prometheus-node-exporter-textfiles";
|
|
in
|
|
{
|
|
imports = [
|
|
(lib.serviceMountWithZpool "prometheus" service_configs.zpool_ssds [
|
|
"/var/lib/prometheus"
|
|
])
|
|
(lib.serviceFilePerms "prometheus" [
|
|
"Z /var/lib/prometheus 0700 prometheus prometheus"
|
|
])
|
|
];
|
|
|
|
services.prometheus = {
|
|
enable = true;
|
|
port = service_configs.ports.private.prometheus.port;
|
|
listenAddress = "127.0.0.1";
|
|
stateDir = "prometheus";
|
|
retentionTime = "90d";
|
|
|
|
exporters = {
|
|
node = {
|
|
enable = true;
|
|
port = service_configs.ports.private.prometheus_node.port;
|
|
listenAddress = "127.0.0.1";
|
|
enabledCollectors = [
|
|
"hwmon"
|
|
"systemd"
|
|
"textfile"
|
|
];
|
|
extraFlags = [
|
|
"--collector.textfile.directory=${textfileDir}"
|
|
];
|
|
};
|
|
|
|
apcupsd = {
|
|
enable = true;
|
|
port = service_configs.ports.private.prometheus_apcupsd.port;
|
|
listenAddress = "127.0.0.1";
|
|
apcupsdAddress = "127.0.0.1:3551";
|
|
};
|
|
};
|
|
|
|
scrapeConfigs = [
|
|
{
|
|
job_name = "prometheus";
|
|
static_configs = [
|
|
{ targets = [ "127.0.0.1:${toString service_configs.ports.private.prometheus.port}" ]; }
|
|
];
|
|
}
|
|
{
|
|
job_name = "node";
|
|
static_configs = [
|
|
{ targets = [ "127.0.0.1:${toString service_configs.ports.private.prometheus_node.port}" ]; }
|
|
];
|
|
}
|
|
{
|
|
job_name = "apcupsd";
|
|
static_configs = [
|
|
{ targets = [ "127.0.0.1:${toString service_configs.ports.private.prometheus_apcupsd.port}" ]; }
|
|
];
|
|
}
|
|
{
|
|
job_name = "llama-cpp";
|
|
static_configs = [
|
|
{ targets = [ "127.0.0.1:${toString service_configs.ports.private.llama_cpp.port}" ]; }
|
|
];
|
|
}
|
|
{
|
|
job_name = "jellyfin";
|
|
static_configs = [
|
|
{ targets = [ "127.0.0.1:${toString service_configs.ports.private.jellyfin_exporter.port}" ]; }
|
|
];
|
|
}
|
|
{
|
|
job_name = "qbittorrent";
|
|
static_configs = [
|
|
{ targets = [ "127.0.0.1:${toString service_configs.ports.private.qbittorrent_exporter.port}" ]; }
|
|
];
|
|
}
|
|
{
|
|
job_name = "igpu";
|
|
static_configs = [
|
|
{ targets = [ "127.0.0.1:${toString service_configs.ports.private.igpu_exporter.port}" ]; }
|
|
];
|
|
}
|
|
];
|
|
};
|
|
|
|
systemd.tmpfiles.rules = [
|
|
"d ${textfileDir} 0755 root root -"
|
|
];
|
|
}
|