changed error handling for prometheus endpoint
This commit is contained in:
parent
894a6b5d4c
commit
5ba9765e88
@ -7,6 +7,10 @@ from waitress import serve
|
|||||||
from pyinfra.config import CONFIG
|
from pyinfra.config import CONFIG
|
||||||
|
|
||||||
|
|
||||||
|
logger = logging.getLogger(__file__)
|
||||||
|
logger.setLevel(CONFIG.service.logging_level)
|
||||||
|
|
||||||
|
|
||||||
def run_probing_webserver(app, host=None, port=None, mode=None):
|
def run_probing_webserver(app, host=None, port=None, mode=None):
|
||||||
if not host:
|
if not host:
|
||||||
host = CONFIG.probing_webserver.host
|
host = CONFIG.probing_webserver.host
|
||||||
@ -43,13 +47,11 @@ def set_up_probing_webserver():
|
|||||||
@app.route("/prometheus", methods=["GET"])
|
@app.route("/prometheus", methods=["GET"])
|
||||||
def get_metrics_from_analysis_endpoint():
|
def get_metrics_from_analysis_endpoint():
|
||||||
try:
|
try:
|
||||||
metric = requests.get(f"{CONFIG.rabbitmq.callback.analysis_endpoint}/prometheus")
|
resp = requests.get(f"{CONFIG.rabbitmq.callback.analysis_endpoint}/prometheus")
|
||||||
metric.raise_for_status()
|
resp.raise_for_status()
|
||||||
return metric.text
|
return resp.text
|
||||||
except requests.exceptions.ConnectionError as err:
|
except Exception as err:
|
||||||
logging.warning(f"Got no metrics from analysis prometheus endpoint: {err}")
|
logger.warning(f"Got no metrics from analysis prometheus endpoint: {err}")
|
||||||
resp = jsonify("no analysis metrics received")
|
|
||||||
resp.status_code = 504
|
|
||||||
return resp
|
return resp
|
||||||
|
|
||||||
return app
|
return app
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user