diff --git a/pyinfra/flask.py b/pyinfra/flask.py index 8196c07..fcddb97 100644 --- a/pyinfra/flask.py +++ b/pyinfra/flask.py @@ -50,11 +50,15 @@ def set_up_probing_webserver(): try: resp = requests.get(f"{CONFIG.rabbitmq.callback.analysis_endpoint}/prometheus") resp.raise_for_status() - return resp.text - except Exception as err: - if not informed_about_missing_prometheus_endpoint: - logger.warning(f"Got no metrics from analysis prometheus endpoint: {err}") - informed_about_missing_prometheus_endpoint = True - return resp + except ConnectionError: + return "" + except requests.exceptions.HTTPError as err: + if resp.status_code == 404: + if not informed_about_missing_prometheus_endpoint: + logger.warning(f"Got no metrics from analysis prometheus endpoint: {err}") + informed_about_missing_prometheus_endpoint = True + else: + raise err + return resp.text return app