@@ -55,6 +55,7 @@ services:
5555 # persist certbot configuration between restarts
5656 - certbot-config:/etc/letsencrypt
5757 - htpasswd-files:/etc/nginx/htpasswd/external
58+ - nginx-logs-exporter:/var/log/nginx/prometheus-nginxlog-exporter/
5859
5960 healthcheck :
6061 test : ["CMD", "service", "nginx", "status"]
@@ -645,6 +646,7 @@ services:
645646 volumes :
646647 - manual-hof:/app/manual-hall-of-fame/
647648 - postgres-backups:/var/lib/postgresql/backups
649+ - nginx-logs-exporter:/var/log/nginx/prometheus-nginxlog-exporter/
648650
649651 healthcheck :
650652 test : ["CMD", "pgrep", "crond"]
@@ -819,6 +821,24 @@ services:
819821 volumes :
820822 - /var/run/docker.sock:/var/run/docker.sock
821823
824+ nginx_logs_exporter :
825+ image : ghcr.io/martin-helmich/prometheus-nginxlog-exporter/exporter:v1
826+ command :
827+ - -config-file=/config.hcl
828+ configs :
829+ - source : nginx_logs_exporter_config
830+ target : /config.hcl
831+
832+ restart : unless-stopped
833+ logging :
834+ driver : $LOGGING_DRIVER
835+ options :
836+ tag : ' {{.Name}}'
837+ networks :
838+ - internal
839+ volumes :
840+ - nginx-logs-exporter:/var/log/nginx/prometheus-nginxlog-exporter/
841+
822842volumes :
823843 postgres : {}
824844 postgres-backups : {}
@@ -835,6 +855,24 @@ volumes:
835855 grafana-data : {}
836856 # shares hosters HoF file between cron and app
837857 manual-hof : {}
858+ # shares nginx log files with log exporter
859+ nginx-logs-exporter : {}
860+
861+ configs :
862+ nginx_logs_exporter_config :
863+ content : |
864+ namespace "nginx" {
865+ format = "$$remote_addr $$host $$remote_user [$$time_local] $$proxy_host \"$$request\" $$status $$body_bytes_sent \"$$http_referer\" \"$$http_user_agent\" \"$$http_x_forwarded_for\""
866+
867+ source = {
868+ files = ["/var/log/nginx/prometheus-nginxlog-exporter/access.log"]
869+ }
870+
871+ relabel "proxy_host" { from = "proxy_host" }
872+ relabel "remote_user" { from = "remote_user" }
873+ }
874+
875+
838876
839877networks :
840878 # disable default network
0 commit comments