ietf-tools / www

A customized CMS for the IETF website
BSD 3-Clause "New" or "Revised" License
22 stars 45 forks source link

chore: Capture Nginx and Gunicorn logs in stdout #434

Closed microamp closed 2 months ago

microamp commented 2 months ago

Fixes #432 and #433

I can see both Nginx and Gunicorn logs when I run kubectl logs -f locally now.

127.0.0.1 - - [23/Apr/2024:04:23:57 +0100] "GET /healthz HTTP/1.0" 200 2 "-" "kube-probe/1.28" "10.244.0.1"
127.0.0.1 - - [23/Apr/2024:04:23:57 +0100] "GET /healthz HTTP/1.0" 200 2 "-" "kube-probe/1.28" "10.244.0.1"
10.244.0.1 - - [23/Apr/2024:03:23:57 +0000] "GET /healthz HTTP/1.1" 200 2 "-" "kube-probe/1.28"
10.244.0.1 - - [23/Apr/2024:03:23:57 +0000] "GET /healthz HTTP/1.1" 200 2 "-" "kube-probe/1.28"
127.0.0.1 - - [23/Apr/2024:04:24:06 +0100] "GET / HTTP/1.0" 200 30624 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:124.0) Gecko/20100101 Firefox/124.0" "127.0.0.1"
127.0.0.1 - - [23/Apr/2024:03:24:06 +0000] "GET / HTTP/1.1" 200 5552 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:124.0) Gecko/20100101 Firefox/124.0"
127.0.0.1 - - [23/Apr/2024:03:24:06 +0000] "GET /static/dist/main.9949552e4686.css HTTP/1.1" 200 324461 "http://localhost:8080/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:124.0) Gecko/20100101 Firefox/124.0"
127.0.0.1 - - [23/Apr/2024:03:24:06 +0000] "GET /static/img/youtube-icon.c20ebf0e90c8.svg HTTP/1.1" 200 930 "http://localhost:8080/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:124.0) Gecko/20100101 Firefox/124.0"

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.

codecov-commenter commented 2 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 82.80%. Comparing base (9a3f9f6) to head (3a0acad).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #434 +/- ## ======================================= Coverage 82.80% 82.80% ======================================= Files 126 126 Lines 2611 2611 ======================================= Hits 2162 2162 Misses 449 449 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

microamp commented 2 months ago

Output should be in json format for easier tagging

Currently as a separate ticket here, https://github.com/ietf-tools/www/issues/433, but happy to combine them

microamp commented 2 months ago

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"
}
microamp commented 2 months ago

@NGPixel Mind having another look when you can please?