2023-08-31 01:55:45 +03:00
|
|
|
{ cluster, config, lib, ... }:
|
2022-05-15 01:34:45 +03:00
|
|
|
let
|
2023-05-27 15:18:02 +03:00
|
|
|
inherit (lib) singleton;
|
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";
|
|
|
|
|
2023-05-26 16:02:28 +03:00
|
|
|
services.grafana-agent = {
|
|
|
|
enable = true;
|
|
|
|
settings = {
|
2023-05-27 15:18:02 +03:00
|
|
|
metrics.global.remote_write = singleton {
|
2023-05-26 17:49:33 +03:00
|
|
|
url = "${cluster.config.links.prometheus-ingest.url}/api/v1/write";
|
|
|
|
};
|
2023-05-26 18:30:36 +03:00
|
|
|
integrations.node_exporter = {
|
|
|
|
enabled = true;
|
2023-08-31 01:55:45 +03:00
|
|
|
instance = config.networking.hostName;
|
2023-05-26 18:30:36 +03:00
|
|
|
enable_collectors = [
|
|
|
|
"systemd"
|
|
|
|
];
|
|
|
|
};
|
2023-05-27 15:18:02 +03:00
|
|
|
logs.configs = singleton {
|
2023-05-26 16:02:28 +03:00
|
|
|
name = "logging";
|
|
|
|
positions.filename = "\${STATE_DIRECTORY:/tmp}/logging-positions.yaml";
|
2023-05-27 15:18:02 +03:00
|
|
|
clients = singleton {
|
2024-08-03 01:56:13 +03:00
|
|
|
url = "${cluster.config.ways.monitoring-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")
|
|
|
|
];
|
|
|
|
};
|
2023-05-26 16:02:28 +03:00
|
|
|
};
|
2022-05-16 01:09:41 +03:00
|
|
|
};
|
|
|
|
};
|
2022-05-15 01:34:45 +03:00
|
|
|
}
|