diff options
author | Vladimir Shushlin <vshushlin@gitlab.com> | 2021-10-14 11:34:05 +0300 |
---|---|---|
committer | Vladimir Shushlin <vshushlin@gitlab.com> | 2021-10-14 11:34:05 +0300 |
commit | 7e8f58590804c78f2c27f51212781d50bb1321ed (patch) | |
tree | 1f06b088c231d9c95a71204886aedfd9285f5cb6 /metrics | |
parent | b0a6ed315e7c8af841974ae0ee83a9fb79242bf8 (diff) | |
parent | 6fe85ca8e1a85e2076c975330fde49c47d86f48a (diff) |
Merge branch '627-source-ip-middleware' into 'master'
feat: add source IP rate limiter middleware
See merge request gitlab-org/gitlab-pages!594
Diffstat (limited to 'metrics')
-rw-r--r-- | metrics/metrics.go | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/metrics/metrics.go b/metrics/metrics.go index b4ac9415..23962dc4 100644 --- a/metrics/metrics.go +++ b/metrics/metrics.go @@ -184,6 +184,34 @@ var ( Help: "The number of backlogged connections waiting on concurrency limit.", }, ) + + // RateLimitSourceIPCacheRequests is the number of cache hits/misses + RateLimitSourceIPCacheRequests = prometheus.NewCounterVec( + prometheus.CounterOpts{ + Name: "gitlab_pages_rate_limit_source_ip_cache_requests", + Help: "The number of source_ip cache hits/misses in the rate limiter", + }, + []string{"op", "cache"}, + ) + + // RateLimitSourceIPCachedEntries is the number of entries in the cache + RateLimitSourceIPCachedEntries = prometheus.NewGaugeVec( + prometheus.GaugeOpts{ + Name: "gitlab_pages_rate_limit_source_ip_cached_entries", + Help: "The number of entries in the cache", + }, + []string{"op"}, + ) + + // RateLimitSourceIPBlockedCount is the number of source IPs that have been blocked by the + // source IP rate limiter + RateLimitSourceIPBlockedCount = prometheus.NewGaugeVec( + prometheus.GaugeOpts{ + Name: "gitlab_pages_rate_limit_source_ip_blocked_count", + Help: "The number of source IP addresses that have been blocked by the rate limiter", + }, + []string{"enforced"}, + ) ) // MustRegister collectors with the Prometheus client @@ -211,5 +239,8 @@ func MustRegister() { LimitListenerMaxConns, LimitListenerConcurrentConns, LimitListenerWaitingConns, + RateLimitSourceIPCacheRequests, + RateLimitSourceIPCachedEntries, + RateLimitSourceIPBlockedCount, ) } |