add retry for prometheus endpoint metric getter
This commit is contained in:
parent
963132afb1
commit
91980ff3ed
@ -1,5 +1,6 @@
|
||||
import requests
|
||||
from flask import Flask, jsonify
|
||||
from retry import retry
|
||||
from waitress import serve
|
||||
|
||||
from pyinfra.config import CONFIG
|
||||
@ -39,8 +40,12 @@ def set_up_probing_webserver():
|
||||
|
||||
@app.route("/prometheus", methods=["GET"])
|
||||
def get_analysis_prometheus_endpoint():
|
||||
prom_endpoint = f"{CONFIG.rabbitmq.callback.analysis_endpoint}/prometheus"
|
||||
metric = requests.get(prom_endpoint)
|
||||
return metric.text
|
||||
@retry(requests.exceptions.ConnectionError, tries=3, delay=5, jitter=(1, 3))
|
||||
def inner():
|
||||
prom_endpoint = f"{CONFIG.rabbitmq.callback.analysis_endpoint}/prometheus"
|
||||
metric = requests.get(prom_endpoint)
|
||||
metric.raise_for_status()
|
||||
return metric.text
|
||||
return inner()
|
||||
|
||||
return app
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user