nix/services/promtail.nix

52 lines
1.3 KiB
Nix
Raw Normal View History

2023-07-04 13:12:45 +02:00
{ config, pkgs, sops-nix, ... }: {
2023-06-30 04:39:01 +02:00
# Promtail Logging
2023-07-04 12:51:41 +02:00
# Import the file:
sops.defaultSopsFile = ./secrets/secrets.yaml;
# Define the secrets
2023-07-04 13:17:50 +02:00
config.sops.secrets.promtail.user = {};
config.sops.secrets.promtail.pass = {};
config.sops.secrets.promtail.url = {};
2023-07-04 12:51:41 +02:00
2023-06-30 04:39:01 +02:00
# Install the package
environment.systemPackages = with pkgs; [
promtail
];
# Configure the package:
# https://mynixos.com/nixpkgs/option/services.promtail.configuration
services.promtail = {
enable = true;
configuration = {
2023-06-30 10:59:07 +02:00
server = {
http_listen_port = 3031;
grpc_listen_port = 0;
};
positions = {
filename = "/tmp/positions.yaml";
};
clients = [{
2023-07-04 13:06:45 +02:00
url = config.sops.secrets.promtail.url.path;
2023-06-30 10:59:07 +02:00
basic_auth = {
2023-07-04 13:06:45 +02:00
username = config.sops.secrets.promtail.user.path;
password = config.sops.secrets.promtail.pass.path;
2023-06-30 11:00:20 +02:00
};
}];
2023-06-30 10:59:07 +02:00
scrape_configs = [{
job_name = "journal";
journal = {
max_age = "12h";
labels = {
job = "systemd-journal";
host = "nixos-p1";
};
};
relabel_configs = [{
source_labels = [ "__journal__systemd_unit" ];
target_label = "unit";
2023-06-30 11:00:20 +02:00
}];
}];
2023-06-30 04:39:01 +02:00
};
};
}