This commit is contained in:
Mitch Ross 2023-02-26 12:04:49 -05:00
parent 6594882b95
commit cb24625fb3
2 changed files with 13 additions and 5 deletions

View File

@ -6,7 +6,8 @@ import logging
import json import json
import os import os
import subprocess as sp import subprocess as sp
from prometheus_client import REGISTRY, generate_latest from prometheus_client import REGISTRY, generate_latest, make_wsgi_app
from werkzeug.middleware.dispatcher import DispatcherMiddleware
import pytz import pytz
import time import time
import traceback import traceback
@ -36,7 +37,8 @@ from frigate.config import FrigateConfig
from frigate.const import CLIPS_DIR, MAX_SEGMENT_DURATION, RECORD_DIR from frigate.const import CLIPS_DIR, MAX_SEGMENT_DURATION, RECORD_DIR
from frigate.models import Event, Recordings from frigate.models import Event, Recordings
from frigate.object_processing import TrackedObject from frigate.object_processing import TrackedObject
from frigate.prometheus_exporter import FrigateCollector from frigate.prometheus_exporter import setupRegistry
from frigate.stats import stats_snapshot from frigate.stats import stats_snapshot
from frigate.util import ( from frigate.util import (
clean_camera_user_pass, clean_camera_user_pass,
@ -83,7 +85,11 @@ def create_app(
app.register_blueprint(bp) app.register_blueprint(bp)
app.wsgi_app = DispatcherMiddleware(app.wsgi_app, {
"/metrics": make_wsgi_app(registry=setupRegistry())
})
return app return app
@ -824,7 +830,7 @@ def stats():
return jsonify(stats) return jsonify(stats)
@bp.route("/metrics") @bp.route("/metrics2")
def metrics(): def metrics():
return generate_latest() return generate_latest()

View File

@ -1,6 +1,8 @@
from prometheus_client import CollectorRegistry from prometheus_client import CollectorRegistry
from prometheus_client.metrics_core import GaugeMetricFamily from prometheus_client.metrics_core import GaugeMetricFamily
from requester import Requester
from frigate.requester import Requester
def setupRegistry(): def setupRegistry():