phase 2: promote services/, tests/, patches/, lib/, scripts/
This commit is contained in:
110
services/grafana/prometheus.nix
Normal file
110
services/grafana/prometheus.nix
Normal file
@@ -0,0 +1,110 @@
|
||||
{
|
||||
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 = "0d"; # 0 disables time-based retention (keep forever)
|
||||
|
||||
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";
|
||||
};
|
||||
|
||||
zfs = {
|
||||
enable = true;
|
||||
port = service_configs.ports.private.prometheus_zfs.port;
|
||||
listenAddress = "127.0.0.1";
|
||||
};
|
||||
};
|
||||
|
||||
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}" ]; }
|
||||
];
|
||||
}
|
||||
{
|
||||
job_name = "zfs";
|
||||
static_configs = [
|
||||
{ targets = [ "127.0.0.1:${toString service_configs.ports.private.prometheus_zfs.port}" ]; }
|
||||
];
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
systemd.tmpfiles.rules = [
|
||||
"d ${textfileDir} 0755 root root -"
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user