make loki, promtail better

(better indices and so on)
This commit is contained in:
Ingolf Wagner 2024-05-15 22:54:12 +02:00
commit 5fbe52eb11
No known key found for this signature in database
GPG key ID: 76BF5F1928B9618B
8 changed files with 81 additions and 19 deletions
nixos/components/monitor

View file

@ -46,16 +46,49 @@ in
{
job_name = "journal";
journal = {
json = true;
max_age = "12h";
labels.job = "systemd-journal";
};
relabel_configs = [
pipeline_stages = [
{
source_labels = [ "__journal__systemd_unit" ];
target_label = "unit";
json.expressions = {
transport = "_TRANSPORT";
unit = "_SYSTEMD_UNIT";
msg = "MESSAGE";
coredump_cgroup = "COREDUMP_CGROUP";
coredump_exe = "COREDUMP_EXE";
coredump_cmdline = "COREDUMP_CMDLINE";
coredump_uid = "COREDUMP_UID";
coredump_gid = "COREDUMP_GID";
};
}
{
source_labels = [ "__journal__transport" ];
target_label = "transport";
# Set the unit (defaulting to the transport like audit and kernel)
template = {
source = "unit";
template = "{{if .unit}}{{.unit}}{{else}}{{.transport}}{{end}}";
};
}
{ labels.coredump_unit = "coredump_unit"; }
{
# Normalize session IDs (session-1234.scope -> session.scope) to limit number of label values
replace = {
source = "unit";
expression = "^(session-\\d+.scope)$";
replace = "session.scope";
};
}
{ labels.unit = "unit"; }
{
# Write the proper message instead of JSON
output.source = "msg";
}
];
relabel_configs = [
{
source_labels = [ "__journal__hostname" ];
target_label = "instance";
}
];
}