Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add to Promtail user_id, override unit if we have a _systemd_user_unit #136

Merged
merged 1 commit into from
Jul 31, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 22 additions & 4 deletions modules/wireguard-monitoring/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,28 @@ in {
host = config.networking.hostName;
};
};
relabel_configs = [{
source_labels = [ "__journal__systemd_unit" ];
target_label = "unit";
}];
relabel_configs = [
{
source_labels = [ "__journal__uid" ];
target_label = "user_id";
}
# some explanation to the next two rules.
# Important to notice that both have the same target_label: unit.
# if we would use only one rule with 2 source_labels, unfortunately only those
# labels will be kept where we have both source labels, so the root level services's log entries are gone.
# Regaring the 2nd rule's regex: "(.*);(.+)", we want to match only those where the __journal__systemd_user_unit
# is not empty, the regex matches and replaces the label with our $2 value which is the value of __journal__systemd_user_unit.
{
source_labels = [ "__journal__systemd_unit" ];
target_label = "unit";
}
{
source_labels = [ "__journal__systemd_unit" "__journal__systemd_user_unit" ];
target_label = "unit";
regex = "(.*);(.+)";
replacement = "$2";
rvem marked this conversation as resolved.
Show resolved Hide resolved
}
];
}];
};
};
Expand Down