diff --git a/mailservice.py b/mailservice.py index 5ad9936f5f586561d9260f0b74ecac9eec51c4f3..1750989de6d821a59f4795fb06ba75fff065bc33 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