2023-05-26 17:15:20 +03:00
|
|
|
{ cluster, lib, ... }:
|
2022-05-15 01:34:45 +03:00
|
|
|
let
|
2022-08-04 00:36:11 +03:00
|
|
|
myNode = cluster.config.vars.mesh.${cluster.config.vars.hostName};
|
2022-05-16 01:09:41 +03:00
|
|
|
|
|
|
|
relabel = from: to: {
|
|
|
|
source_labels = [ from ];
|
|
|
|
target_label = to;
|
|
|
|
};
|
2022-08-04 00:36:11 +03:00
|
|
|
in {
|
2022-05-31 22:03:44 +03:00
|
|
|
services.journald.extraConfig = "Storage=volatile";
|
|
|
|
|
2022-05-15 01:34:45 +03:00
|
|
|
services.prometheus.exporters = {
|
|
|
|
node = {
|
|
|
|
enable = true;
|
2022-08-04 00:36:11 +03:00
|
|
|
listenAddress = myNode.meshIp;
|
2023-05-08 22:25:35 +03:00
|
|
|
enabledCollectors = [
|
|
|
|
"systemd"
|
|
|
|
];
|
2022-05-15 01:34:45 +03:00
|
|
|
};
|
|
|
|
};
|
2022-05-16 01:09:41 +03:00
|
|
|
|
2022-06-18 20:47:02 +03:00
|
|
|
systemd.services.prometheus-node-exporter = {
|
2022-08-04 00:36:11 +03:00
|
|
|
after = [ "wireguard-wgmesh.service" ];
|
2022-06-18 20:47:02 +03:00
|
|
|
serviceConfig.RestartSec = "10s";
|
|
|
|
};
|
2022-05-27 02:31:46 +03:00
|
|
|
|
2023-05-26 16:02:28 +03:00
|
|
|
services.grafana-agent = {
|
|
|
|
enable = true;
|
|
|
|
settings = {
|
|
|
|
logs.configs = lib.singleton {
|
|
|
|
name = "logging";
|
|
|
|
positions.filename = "\${STATE_DIRECTORY:/tmp}/logging-positions.yaml";
|
2022-05-16 01:09:41 +03:00
|
|
|
clients = [
|
2022-08-04 00:36:11 +03:00
|
|
|
{ url = "${cluster.config.links.loki-ingest.url}/loki/api/v1/push"; }
|
2022-05-16 01:09:41 +03:00
|
|
|
];
|
|
|
|
scrape_configs = [
|
|
|
|
{
|
|
|
|
job_name = "journal";
|
|
|
|
journal = {
|
|
|
|
max_age = "12h";
|
2022-08-04 00:36:11 +03:00
|
|
|
labels.host = cluster.config.vars.hostName;
|
2022-05-16 01:09:41 +03:00
|
|
|
};
|
|
|
|
relabel_configs = [
|
|
|
|
(relabel "__journal__systemd_unit" "systemd_unit")
|
|
|
|
(relabel "__journal__hostname" "machine_name")
|
|
|
|
(relabel "__journal__exe" "executable")
|
|
|
|
(relabel "__journal__comm" "command")
|
|
|
|
(relabel "__journal__boot_id" "systemd_boot_id")
|
|
|
|
(relabel "__journal__systemd_cgroup" "systemd_cgroup")
|
|
|
|
(relabel "__journal_syslog_identifier" "syslog_identifier")
|
|
|
|
];
|
|
|
|
}
|
|
|
|
];
|
2023-05-26 16:02:28 +03:00
|
|
|
};
|
2022-05-16 01:09:41 +03:00
|
|
|
};
|
|
|
|
};
|
2022-05-15 01:34:45 +03:00
|
|
|
}
|