2023-01-20 21:45:00 +01:00
|
|
|
{ config, pkgs, values, ... }:
|
2024-01-09 10:03:42 +01:00
|
|
|
let
|
|
|
|
metricsHost = "192.168.10.175" # defiant.home.feal.no
|
|
|
|
in {
|
2023-01-20 21:45:00 +01:00
|
|
|
services.prometheus.exporters.node = {
|
|
|
|
enable = true;
|
|
|
|
port = 9100;
|
|
|
|
enabledCollectors = [ "systemd" ];
|
|
|
|
};
|
|
|
|
|
2023-12-26 12:21:30 +01:00
|
|
|
networking.firewall = {
|
|
|
|
# TODO: Move this into the node-exporter systemd service
|
|
|
|
allowedTCPPorts = [ 9100 ];
|
|
|
|
extraCommands = ''
|
2024-01-09 10:03:42 +01:00
|
|
|
iptables -A INPUT -p tcp -m tcp --source ${metricsHost}/32 --dport 9100 -j ACCEPT
|
2023-12-26 12:21:30 +01:00
|
|
|
iptables -A INPUT -p tcp -m tcp --dport 9100 -j DROP
|
|
|
|
'';
|
2023-01-20 21:45:00 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
services.promtail = {
|
|
|
|
enable = true;
|
|
|
|
configuration = {
|
|
|
|
server = {
|
|
|
|
http_listen_port = 28183;
|
|
|
|
grpc_listen_port = 0;
|
|
|
|
};
|
|
|
|
clients = [
|
|
|
|
{
|
2024-01-09 10:03:42 +01:00
|
|
|
url = "http://${metricsHost}:3100/loki/api/v1/push";
|
2023-01-20 21:45:00 +01:00
|
|
|
}
|
|
|
|
];
|
|
|
|
scrape_configs = [
|
|
|
|
{
|
|
|
|
job_name = "systemd-journal";
|
|
|
|
journal = {
|
|
|
|
max_age = "12h";
|
|
|
|
labels = {
|
|
|
|
job = "systemd-journal";
|
|
|
|
host = config.networking.hostName;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
relabel_configs = [
|
|
|
|
{
|
|
|
|
source_labels = [ "__journal__systemd_unit" ];
|
|
|
|
target_label = "unit";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
source_labels = [ "__journal_priority_keyword" ];
|
|
|
|
target_label = "level";
|
|
|
|
}
|
|
|
|
];
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|