Go to All Forums

nginx Logs sourced from Container Logs

Hi,

We use an nginx container as the API gateway to our infrastructure. We currently parse the Docker container logs as described www.site24x7.com/help/log-management/docker-container-logs.html.

How do we then parse these log outputs to extract the nginx access logs?

e.g., instead of pointing at /var/log/nginx/access.log we want to point out the container logs for a given container.

Like (2) Reply
Replies (1)

Dear Nigel,

                Please create a new log type with the below sample logs and log pattern and then map the Nginx container log path in the log profile.

Sample Logs

{"log":"test.domain.com 127.0.0.1 - - [18/May/2021:23:59:18 +0530] \"GET / HTTP/1.1\" 200 612 \"-\" \"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36\"","stream":"stdout","time":"2019-06-04T11:29:44.415074847Z"}
{"log":"test.domain.com 127.0.0.1 - - [18/May/2021:23:59:18 +0530] \"GET / HTTP/1.1\" 200 612 \"-\" \"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36\"","stream":"stdout","time":"2019-06-04T11:29:44.415074847Z"}
{"log":"test.domain.com 127.0.0.1 - - [18/May/2021:23:59:18 +0530] \"GET / HTTP/1.1\" 200 612 \"-\" \"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36\"","stream":"stdout","time":"2019-06-04T11:29:44.415074847Z"}

Log Pattern
json $log:pattern:$DomainName$ $RemoteAddress:ip$ - $RemoteUser$ [$DateTime:date$] "$Method$ $RequestURI$ $Protocol$" $Status:number$ $BytesSent:number$ "$Referer$" "$UserAgent$"$

Once the log types is created please use the below log file path to create the log profile.

File Path: /var/lib/docker/containers/<NginxContainerId>/*-json.log

 

Regards,

Magesh Rajan

Like (0) Reply

Was this post helpful?