From 2dd3b9f830659ff4caf0c9a58dd22e2d078ff73f Mon Sep 17 00:00:00 2001 From: Jan Hartig <jan.hartig@ptb.de> Date: Wed, 23 Aug 2023 15:19:12 +0000 Subject: [PATCH] Fix metrics stuff --- mailservice.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/mailservice.py b/mailservice.py index 5ad9936..1750989 100644 --- a/mailservice.py +++ b/mailservice.py @@ -107,11 +107,16 @@ def main(end): try: try: - auth = HTTPBasicAuth(config["METRICS"]["USER"], config["MONITORING"]["PASS"]) + auth = HTTPBasicAuth(config["METRICS"]["USER"], config["METRICS"]["PASS"]) except KeyError: auth = None - requests.post(config["METRICS"]["URL"], json=metrics, auth=auth) + r = requests.post(config["METRICS"]["URL"], json=metrics, auth=auth) + + try: + r.raise_for_status() + except requests.HTTPError as e: + print("[MAILSERVICE] Could not send metrics to server: {}".format(e)) except KeyError: pass -- GitLab