depot/cluster/services/monitoring/client.nix

51 lines
1.5 KiB
Nix
Raw Normal View History

2023-08-31 01:55:45 +03:00
{ cluster, config, lib, ... }:
let
2023-05-27 15:18:02 +03:00
inherit (lib) singleton;
relabel = from: to: {
source_labels = [ from ];
target_label = to;
};
in {
services.journald.extraConfig = "Storage=volatile";
services.grafana-agent = {
enable = true;
settings = {
2023-05-27 15:18:02 +03:00
metrics.global.remote_write = singleton {
url = "${cluster.config.links.prometheus-ingest.url}/api/v1/write";
};
integrations.node_exporter = {
enabled = true;
2023-08-31 01:55:45 +03:00
instance = config.networking.hostName;
enable_collectors = [
"systemd"
];
};
2023-05-27 15:18:02 +03:00
logs.configs = singleton {
name = "logging";
positions.filename = "\${STATE_DIRECTORY:/tmp}/logging-positions.yaml";
2023-05-27 15:18:02 +03:00
clients = singleton {
url = "${cluster.config.ways.ingest-logs.url}/loki/api/v1/push";
2023-05-27 15:18:02 +03:00
};
scrape_configs = singleton {
job_name = "journal";
journal = {
max_age = "12h";
2023-08-31 01:55:45 +03:00
labels.host = config.networking.hostName;
2023-05-27 15:18:02 +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")
];
};
};
};
};
}