Skip to content

Commit

Permalink
[Chore] Relabel '__journal_container_name' when docker is enabled
Browse files Browse the repository at this point in the history
Problem: Some of our services run as containers orchestrated not
by systemd. Currently, logs for such containers aren't easily
searchable in promtail.

Solution: Add '__journal_container_name' to the promtail relabeling in
case docker is enabled within the configuration
  • Loading branch information
rvem committed Apr 9, 2024
1 parent c07005c commit f526c5d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions modules/wireguard-monitoring/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,11 @@ in {
regex = "(.*);(.+)";
replacement = "$2";
}
];
}] ++ (if config.services.nginx.enable
then [{
] ++ lib.optional (config.virtualisation.docker.enable) {
source_labels = [ "__journal_container_name" ];
target_label = "container";
};
}] ++ (lib.optional (config.services.nginx.enable) {
job_name = "nginx-error-logs";
static_configs = [{
targets = [ "localhost" ];
Expand All @@ -91,7 +93,7 @@ in {
__path__ = "/var/log/nginx/*error.log";
};
}];
}] else [ ]);
});
};
};

Expand Down

0 comments on commit f526c5d

Please sign in to comment.