nixfleet/modules/promtail/default.nix
Andrea Ciceri cba0555c38
Some checks failed
EVAL aarch64-linux.sisko
BUILD aarch64-linux.sisko
UPLOAD aarch64-linux.sisko
DOWNLOAD aarch64-linux.sisko
CACHIX aarch64-linux.sisko
ATTIC aarch64-linux.sisko
/ test (push) Successful in 1m17s
{host}.fleet -> {host}.wg.aciceri.dev
2025-03-14 16:07:32 +01:00

58 lines
1.2 KiB
Nix

{
pkgs,
lib,
config,
...
}:
let
conf = {
server = {
http_listen_port = 28183;
grpc_listen_port = 0;
};
clients = [
{
url = "http://sisko.wg.aciceri.dev:${
builtins.toString config.services.loki.configuration.server.http_listen_port or 3100
}/loki/api/v1/push";
}
];
positions = {
filename = "/tmp/positions.yaml";
};
scrape_configs = [
{
job_name = "journal";
journal = {
max_age = "12h";
labels = {
job = "systemd-journal";
host = config.networking.hostName;
};
};
relabel_configs = [
{
source_labels = [ "__journal__systemd_unit" ];
target_label = "unit";
}
];
}
];
};
configFile = pkgs.writeTextFile {
name = "promtail.yaml";
text = lib.generators.toYAML { } conf;
};
in
{
systemd.services.promtail = {
description = "Promtail service for Loki";
wantedBy = [ "multi-user.target" ];
serviceConfig = {
ExecStart = ''
${pkgs.grafana-loki}/bin/promtail --config.file ${configFile}
'';
};
};
}