2022-06-12 15:39:15 +00:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
pkgs,
|
|
|
|
lib,
|
|
|
|
...
|
|
|
|
}: let
|
2022-03-06 10:57:52 +00:00
|
|
|
promtail_config = {
|
|
|
|
server = {
|
|
|
|
http_listen_port = 28183;
|
|
|
|
grpc_listen_port = 0;
|
|
|
|
};
|
|
|
|
positions = {
|
|
|
|
filename = "/tmp/positions.yaml";
|
|
|
|
};
|
|
|
|
client = {
|
2022-05-03 09:31:27 +00:00
|
|
|
url = "http://nixos-8gb-fsn1-1.int.chir.rs:3100/loki/api/v1/push";
|
2022-03-06 10:57:52 +00:00
|
|
|
external_labels.host = config.networking.hostName;
|
|
|
|
};
|
|
|
|
scrape_configs = [
|
|
|
|
{
|
|
|
|
job_name = "journal";
|
|
|
|
journal = {
|
|
|
|
max_age = "12h";
|
|
|
|
labels.job = "systemd-journal";
|
|
|
|
};
|
|
|
|
relabel_configs = [
|
|
|
|
{
|
2022-06-12 15:39:15 +00:00
|
|
|
source_labels = ["__journal__systemd_unit"];
|
2022-03-06 10:57:52 +00:00
|
|
|
target_label = "unit";
|
|
|
|
}
|
|
|
|
];
|
|
|
|
}
|
|
|
|
];
|
2022-03-06 10:44:08 +00:00
|
|
|
};
|
2022-06-12 15:39:15 +00:00
|
|
|
promtail_yml = pkgs.writeText "promtail.yml" (lib.generators.toYAML {} promtail_config);
|
|
|
|
in {
|
2022-03-06 10:44:08 +00:00
|
|
|
systemd.services.promtail = {
|
|
|
|
description = "Promtail service for Loki";
|
2022-06-12 15:39:15 +00:00
|
|
|
wantedBy = ["multi-user.target"];
|
2022-03-06 10:44:08 +00:00
|
|
|
|
|
|
|
serviceConfig = {
|
|
|
|
ExecStart = ''
|
2022-03-06 10:57:52 +00:00
|
|
|
${pkgs.grafana-loki}/bin/promtail --config.file ${promtail_yml}
|
2022-03-06 10:44:08 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|