summaryrefslogtreecommitdiff
path: root/lib/gitlab/prometheus_client.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/prometheus_client.rb')
-rw-r--r--lib/gitlab/prometheus_client.rb15
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/gitlab/prometheus_client.rb b/lib/gitlab/prometheus_client.rb
index 56e1154a672..965349ad711 100644
--- a/lib/gitlab/prometheus_client.rb
+++ b/lib/gitlab/prometheus_client.rb
@@ -42,6 +42,15 @@ module Gitlab
response_body == HEALTHY_RESPONSE
end
+ def ready?
+ response = get(ready_url, {})
+
+ # From Prometheus docs: This endpoint returns 200 when Prometheus is ready to serve traffic (i.e. respond to queries).
+ response.code == 200
+ rescue => e
+ raise PrometheusClient::UnexpectedResponseError, "#{e.message}"
+ end
+
def proxy(type, args)
path = api_path(type)
get(path, args)
@@ -103,7 +112,11 @@ module Gitlab
end
def health_url
- [api_url, '-/healthy'].join('/')
+ "#{api_url}/-/healthy"
+ end
+
+ def ready_url
+ "#{api_url}/-/ready"
end
private