Stitching things up
This commit is contained in:
16
dashboard/prometheus_utils/query.py
Normal file
16
dashboard/prometheus_utils/query.py
Normal file
@@ -0,0 +1,16 @@
|
||||
import requests
|
||||
|
||||
from watcher_visio.settings import PROMETHEUS_URL
|
||||
|
||||
def query_prometheus(query):
|
||||
url = f"{PROMETHEUS_URL}/api/v1/query"
|
||||
params = {
|
||||
"query": query,
|
||||
}
|
||||
response = requests.get(url=url, params=params)
|
||||
response.raise_for_status()
|
||||
result = response.json()["data"]["result"]
|
||||
if len(result) > 1:
|
||||
return result[0]["value"][1]
|
||||
else:
|
||||
return result[0]["values"]
|
||||
Reference in New Issue
Block a user