-
Notifications
You must be signed in to change notification settings - Fork 43
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
chore: Capture Nginx and Gunicorn logs in stdout #434
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #434 +/- ##
=======================================
Coverage 82.80% 82.80%
=======================================
Files 126 126
Lines 2611 2611
=======================================
Hits 2162 2162
Misses 449 449 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Output should be in json format for easier tagging
Currently as a separate ticket here, #433, but happy to combine them |
Application logs are now in JSON format. e.g. {"remote_host": "127.0.0.1", "remote_logname": "-", "remote_user": "-", "timestamp": "[24/Apr/2024:10:04:55 +0100]", "request": "GET /announcements/ HTTP/1.0", "status_code": "200", "response_size": "37152", "referrer": "http://localhost:8080/announcements/reappointment-of-eliot-lear-as-independent-submission-editor/", "user_agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36", "x_forwarded_for": "127.0.0.1"} Pretty-printed: {
"remote_host": "127.0.0.1",
"remote_logname": "-",
"remote_user": "-",
"timestamp": "[24/Apr/2024:10:04:55 +0100]",
"request": "GET /announcements/ HTTP/1.0",
"status_code": "200",
"response_size": "37152",
"referrer": "http://localhost:8080/announcements/reappointment-of-eliot-lear-as-independent-submission-editor/",
"user_agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36",
"x_forwarded_for": "127.0.0.1"
} |
"response_size": "%(b)s", | ||
"referrer": "%(f)s", | ||
"user_agent": "%(a)s", | ||
"x_forwarded_for": "%({x-forwarded-for}i)s", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"%({X-Forwarded-For}i)s"
is now all lowercase, i.e.
"%({x-forwarded-for}i)s"
as per the official documentation
Use lowercase for header and environment variable names, and put {...}x names inside %(...)s. For example:
%({x-forwarded-for}i)s
https://docs.gunicorn.org/en/stable/settings.html#access-log-format
@NGPixel Mind having another look when you can please? |
Fixes #432 and #433
I can see both Nginx and Gunicorn logs when I run
kubectl logs -f
locally now.However, I'm not sure about the second commit. Configuring the Grafana agent to read from a file path may be cleaner (e.g.
/var/log/nginx/access.log
). To be discussed further.Update: Fixing #433 in the same PR now.