Skip to content
Snippets Groups Projects

Deploy prometheus through kubernetes and autoconnect to cluster

Merged Paweł Chojnacki requested to merge pawel/connect_to_prometheus_through_proxy-30480 into master
All threads resolved!
Compare and Show latest version
2 files
+ 21
10
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -50,10 +50,12 @@ def get(path, args)
response = rest_client[path].get(params: args)
handle_response(response)
rescue SocketError
raise PrometheusError, "Can't connect to #{url}"
raise PrometheusError, "Can't connect to #{rest_client.url}"
rescue OpenSSL::SSL::SSLError
raise PrometheusError, "#{url} contains invalid SSL data"
rescue HTTParty::Error
raise PrometheusError, "#{rest_client.url} contains invalid SSL data"
rescue RestClient::ExceptionWithResponse => ex
handle_exception_response(ex.response)
rescue RestClient::Exception
raise PrometheusError, "Network connection error"
end
@@ -61,7 +63,14 @@ def handle_response(response)
json_data = JSON.parse(response.body)
if response.code == 200 && json_data['status'] == 'success'
json_data['data'] || {}
elsif response.code == 400
else
raise PrometheusError, "#{response.code} - #{response.body}"
end
end
def handle_exception_response(response)
if response.code == 400
json_data = JSON.parse(response.body)
raise PrometheusError, json_data['error'] || 'Bad data received'
else
raise PrometheusError, "#{response.code} - #{response.body}"
Loading