How to calculate Request Per Second (RPS) from GitLab logs
Description
This article explains how to calculate Request Per Second (RPS) metrics from GitLab logs. This is useful for performance monitoring, capacity planning, and troubleshooting high load situations on your GitLab instance. The results of the command on this article can be compared directly to GitLab's reference architectures
Environment
GitLab Self-Managed
Prerequisites
- Access to GitLab server logs
- Basic knowledge of Linux command line
- Ruby installed (for script method)
-
datamash
utility installed (for command line method)
Solution
Method 1: Using the get-rps.rb script
-
Clone or download the script from the GitLab Support Toolbox repository:
git clone https://gitlab.com/gitlab-com/support/toolbox/dotfiles.git
-
Navigate to the scripts directory:
cd dotfiles/scripts
-
Run the get-rps.rb script against your GitLab access logs:
ruby get-rps.rb /var/log/gitlab/nginx/gitlab_access.log /var/log/gitlab/gitlab-shell/gitlab-shell
-
Compare output with GitLab referece architecture:
Method 2: Using Linux commands on Omnibus logs
We can manually collect logs or use gitlabSOS
-
Count of web Git push requests:
\grep "git-receive-pack" /var/log/gitlab/nginx/gitlab_access.log | \grep "200" | awk '{print $4}' | sort | uniq -c | tr -d "[" | datamash -s -i -W mean 1
-
Count of SSH Git push requests:
\grep "git-receive-pack" /var/log/gitlab/gitlab-shell/gitlab-shell.log | jq '.| .time' | sort | uniq -c | tr -d "[" | datamash -s -i -W mean 1
-
Count of Web Git pull requests:
\grep "git-upload-pack" /var/log/gitlab/nginx/gitlab_access.log | \grep "200" | awk '{print $4}' | sort | uniq -c | tr -d "[" | datamash -s -i -W mean 1
-
Count of SSH Git pull requests:
\grep "git-upload-pack" /var/log/gitlab/gitlab-shell/gitlab-shell.log | jq '.| .time' | sort | uniq -c | tr -d "[" | datamash -s -i -W mean 1
-
Count API requests:
\grep api /var/log/gitlab/nginx/gitlab_access.log | \grep -v "jobs/request" | awk '{print $4}' | sort | uniq -c | tr -d "[" | datamash -s -i -W mean 1
-
Count Web requests:
\grep -v git-upload-pack /var/log/gitlab/nginx/gitlab_access.log | \grep -v "api" | grep -v git-receive-pack | awk '{print $4}' | sort | uniq -c | tr -d "[" | datamash -s -i -W mean 1
Method 3: Using Linux commands on Kubernetes logs
For Kubernetes we have to use the webservice_gitlab-workhorse.log
in KubeSOS.
This might affect the accuarcy of the data.
-
Count of web Git push requests:
\grep "git-receive-pack" webservice_gitlab-workhorse.log | \grep "200" | cut -d. -f 1 |awk '{print $1}' | sort | uniq -c | datamash -s -i -W mean 1
-
Count of Web Git pull requests:
\grep "git-upload-pack" webservice_gitlab-workhorse.log | \grep "200" | cut -d. -f 1 |awk '{print $1}' | sort | uniq -c | datamash -s -i -W mean 1
-
Count API requests:
\grep api /webservice_gitlab-workhorse.log| \grep -v "jobs/request" | cut -d. -f 1 |awk '{print $1}' | sort | uniq -c | datamash -s -i -W mean 1
-
Count Web requests:
\grep -v git-upload-pack webservice_gitlab-workhorse.log | \grep -v "api" | \grep -v git-receive-pack | cut -d. -f 1 |awk '{print $1}' | sort | uniq -c | datamash -s -i -W mean 1
Verification
After running either method, you should see output showing:
- For the script: A summary of RPS statistics
- For the command line: Either the mean RPS value or a list of timestamps with request counts
The results should help you understand your GitLab instance's request load patterns.
Additional Information
- The
git-upload-pack
filter focuses specifically on Git fetch/clone operations - The
git receive-pack
filter focuses specifically on Git push operations - The "200" filter ensures you're only counting successful requests as Git HTTP request ar always unathenticated first
- For more comprehensive analysis, consider examining different request types or status codes
- High RPS values might indicate heavy usage periods or potential abuse