Skip to content
Snippets Groups Projects
Unverified Commit a99c16aa authored by Varac's avatar Varac
Browse files

alertmanager-status: Move requests.get into try/execpt

parent f753a4b6
Branches
No related tags found
No related merge requests found
...@@ -21,14 +21,14 @@ def get_alerts(url, password, port=443, user="admin"): ...@@ -21,14 +21,14 @@ def get_alerts(url, password, port=443, user="admin"):
""" """
api_url = f"{url}/api/v2/alerts" api_url = f"{url}/api/v2/alerts"
query = {"silenced": "false"} query = {"silenced": "false"}
req = requests.get(api_url, auth=(user, password), params=query)
alerts_json = req.json()
count = 0 count = 0
alerts = [] alerts = []
state = "unknown" state = "unknown"
try: try:
req = requests.get(api_url, auth=(user, password), params=query)
alerts_json = req.json()
for alert in alerts_json: for alert in alerts_json:
# pp = pprint.PrettyPrinter(indent=2) # pp = pprint.PrettyPrinter(indent=2)
# pp.pprint(alert) # pp.pprint(alert)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment