nix/services/promtail.nix
2023-07-12 23:41:12 +09:00

51 lines
No EOL
1.2 KiB
Nix

{ config, pkgs, hostname, ... }: {
# Promtail Logging
# Set up the secret for the password:
sops.secrets.promtail-pass = {
owner = "promtail";
sopsFile = ../secrets/secrets.yaml;
restartUnits = [ "promtail.service" ];
};
# Install the package
environment.systemPackages = with pkgs; [
promtail
];
# Configure the package:
# https://mynixos.com/nixpkgs/option/services.promtail.configuration
services.promtail = {
enable = true;
configuration = {
server = {
http_listen_port = 3031;
grpc_listen_port = 0;
};
positions = {
filename = "/tmp/positions.yaml";
};
clients = [{
url = "https://loki.sysctl.io/loki/api/v1/push";
basic_auth = {
username = "loki-sa";
password_file = config.sops.secrets.promtail-pass.path;
};
}];
scrape_configs = [{
job_name = "journal";
journal = {
max_age = "12h";
labels = {
job = "systemd-journal";
host = "${hostname}";
};
};
relabel_configs = [{
source_labels = [ "__journal__systemd_unit" ];
target_label = "unit";
}];
}];
};
};
}