feat: add prometheus flask metrics
This commit is contained in:
parent
c50d341c26
commit
4dd0c4ed22
2 changed files with 5 additions and 1 deletions
|
@ -20,18 +20,20 @@ from app.models.automation import Automation, AutomationState
|
|||
from app.portal import portal
|
||||
from app.portal.report import report
|
||||
from app.tfstate import tfstate
|
||||
from prometheus_flask_exporter import PrometheusMetrics
|
||||
|
||||
app = Flask(__name__)
|
||||
app.config.from_file("../config.yaml", load=yaml.safe_load)
|
||||
|
||||
# create new registry to avoid multiple metrics registration in global REGISTRY
|
||||
registry = CollectorRegistry()
|
||||
metrics = PrometheusMetrics(app, registry=registry)
|
||||
|
||||
app.wsgi_app = DispatcherMiddleware(app.wsgi_app, { # type: ignore[method-assign]
|
||||
'/metrics': make_wsgi_app(registry)
|
||||
})
|
||||
|
||||
#register default collectors to our new registry
|
||||
# register default collectors to our new registry
|
||||
collectors = list(REGISTRY._collector_to_names.keys())
|
||||
for collector in collectors:
|
||||
registry.register(collector)
|
||||
|
@ -137,6 +139,7 @@ class AutomationCollector(Collector):
|
|||
ok.add_metric(["automation_state"], 0)
|
||||
yield ok
|
||||
|
||||
|
||||
# register all custom collectors to registry
|
||||
if not_migrating() and 'DISABLE_METRICS' not in os.environ:
|
||||
registry.register(DefinedProxiesCollector())
|
||||
|
|
|
@ -17,6 +17,7 @@ markupsafe
|
|||
nose
|
||||
openpyxl
|
||||
prometheus_client
|
||||
prometheus_flask_exporter
|
||||
pytest
|
||||
python-dateutil
|
||||
python-gitlab
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue