37 lines
1 KiB
Nix
37 lines
1 KiB
Nix
{
|
|
config,
|
|
lib,
|
|
...
|
|
}:
|
|
let
|
|
cfg = config.bagel.monitoring.exporters.nginx;
|
|
inherit (lib) mkEnableOption mkIf;
|
|
logFormat = ''$remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent" rt=$request_time uct="$upstream_connect_time" uht="$upstream_header_time" urt="$upstream_response_time"'';
|
|
in
|
|
{
|
|
options.bagel.monitoring.exporters.nginx.enable = (mkEnableOption "Nginx access.log exporter") // { default = config.services.nginx.enable; };
|
|
|
|
config = mkIf cfg.enable {
|
|
services.nginx.appendHttpConfig = ''
|
|
log_format ours '${logFormat}';
|
|
access_log /var/log/nginx/access.log ours;
|
|
'';
|
|
|
|
services.prometheus.exporters.nginxlog = {
|
|
enable = true;
|
|
port = 9103;
|
|
group = "nginx";
|
|
settings.namespaces = [
|
|
{
|
|
name = "nginx";
|
|
format = logFormat;
|
|
source.files = ["/var/log/nginx/access.log"];
|
|
}
|
|
];
|
|
};
|
|
|
|
bagel.meta.monitoring.exporters = [
|
|
{ port = 9103; }
|
|
];
|
|
};
|
|
} |