Commit 83e89f4f authored by Bob Van Landuyt's avatar Bob Van Landuyt

Add /-/metrics as a health endpoint to RackAttack

The metrics endpoint is the endpoint hit by a prometheus-scrape. It
should not be rate-limited.
parent f7562c83
...@@ -24,7 +24,7 @@ module Gitlab ...@@ -24,7 +24,7 @@ module Gitlab
end end
def health_check_request? def health_check_request?
path =~ %r{^/-/(health|liveness|readiness)} path =~ %r{^/-/(health|liveness|readiness|metrics)}
end end
def product_analytics_collector_request? def product_analytics_collector_request?
......
...@@ -106,7 +106,7 @@ RSpec.describe 'Rack Attack global throttles' do ...@@ -106,7 +106,7 @@ RSpec.describe 'Rack Attack global throttles' do
let(:request_jobs_url) { '/api/v4/jobs/request' } let(:request_jobs_url) { '/api/v4/jobs/request' }
let(:runner) { create(:ci_runner) } let(:runner) { create(:ci_runner) }
it 'does not cont as unauthenticated' do it 'does not count as unauthenticated' do
(1 + requests_per_period).times do (1 + requests_per_period).times do
post request_jobs_url, params: { token: runner.token } post request_jobs_url, params: { token: runner.token }
expect(response).to have_gitlab_http_status(:no_content) expect(response).to have_gitlab_http_status(:no_content)
...@@ -114,6 +114,17 @@ RSpec.describe 'Rack Attack global throttles' do ...@@ -114,6 +114,17 @@ RSpec.describe 'Rack Attack global throttles' do
end end
end end
context 'when the request is to a health endpoint' do
let(:health_endpoint) { '/-/metrics' }
it 'does not throttle the requests' do
(1 + requests_per_period).times do
get health_endpoint
expect(response).to have_gitlab_http_status(:ok)
end
end
end
it 'logs RackAttack info into structured logs' do it 'logs RackAttack info into structured logs' do
requests_per_period.times do requests_per_period.times do
get url_that_does_not_require_authentication get url_that_does_not_require_authentication
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment