Skip to content
Snippets Groups Projects
Verified Commit 44f75fd8 authored by lelutin's avatar lelutin
Browse files

Add some helpful jq commands to trawl through logs

reading json logs is not natural and jq can be complicated to use
sometimes.
parent 619bf201
No related branches found
No related tags found
No related merge requests found
Pipeline #185990 passed with warnings
......@@ -647,6 +647,29 @@ This command also shows general info about the GitLab instance:
it is especially useful to find on-disk files and package versions.
### Filtering through json logs
The most useful log to look into when trying to identify errors or traffic
patterns is `/var/log/gitlab-rails/production_json.log`. It shows all of the
activity on the web interface.
Since the file is formatted in JSON, to filter through this file, you need to
use `jq` to filter lines. Here are some useful examples that you can build upon
for your search:
To find requests that got a server error (e.g. 500 http status code) response:
jq 'select(.status==500)' production_json.log
To get lines only from a defined period of time:
jq --arg s '2024-07-16T07:10:00' --arg e '2024-07-16T07:19:59' 'select(.time | . >= $s and . <= $e + "z")' prodcution_json.log
To identify the individual IP addresses with the highest number of requests for
the day:
jq -rC '.remote_ip' production_json.log | sort | uniq -c | sort -n | tail -10
### GitLab pages not found
If you're looking for a way to track GitLab pages error, know that the
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment