Skip to content

Commit 9f44bd8

Browse files
author
Anand Sanmukhani
committed
Fix request query for get_current_metric_value
1 parent 798eeb2 commit 9f44bd8

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

prometheus_connect/prometheus_connect.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
class PrometheusConnect:
2323
"""docstring for Prometheus."""
24-
def __init__(self, url='', token=None):
24+
def __init__(self, url='127.0.0.1:9090', token=None):
2525
self.headers = { 'Authorization': "bearer {}".format(token) }
2626
self.url = url
2727
self.prometheus_host = urlparse(self.url).netloc
@@ -55,6 +55,11 @@ def get_current_metric_value(self, metric_name, label_config = None):
5555
query = metric_name + "{" + ",".join(label_list) + "}"
5656
else:
5757
query = metric_name
58+
59+
response = requests.get('{0}/api/v1/query'.format(self.url), # using the query API to get raw data
60+
params={'query': query},#label_config},
61+
verify=False, # Disable ssl certificate verification temporarily
62+
headers=self.headers)
5863

5964
if response.status_code == 200:
6065
data += response.json()['data']['result']

0 commit comments

Comments
 (0)