From 48ef416dfbe0f01decd4f7f981a48a3cbeab5bcf Mon Sep 17 00:00:00 2001 From: Mike Lang Date: Wed, 11 Nov 2020 00:43:22 +1100 Subject: [PATCH] restreamer, thrimshim: Allow /metrics/* in addition to /metrics This allows the metrics proxying from nginx to work even if the path is not rewritten, which is hard to do in k8s. --- restreamer/restreamer/main.py | 7 +++++++ thrimshim/thrimshim/main.py | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/restreamer/restreamer/main.py b/restreamer/restreamer/main.py index bef5c72..a3784a8 100644 --- a/restreamer/restreamer/main.py +++ b/restreamer/restreamer/main.py @@ -86,6 +86,13 @@ def metrics(): """Return current metrics in prometheus metrics format""" return prom.generate_latest() +# To make nginx proxying simpler, we want to allow /metrics/* to work +@app.route('/metrics/') +@request_stats +def metrics_with_trailing(trailing): + """Expose Prometheus metrics.""" + return prometheus_client.generate_latest() + @app.route('/files') @request_stats def list_channels(): diff --git a/thrimshim/thrimshim/main.py b/thrimshim/thrimshim/main.py index 34be873..f099c26 100644 --- a/thrimshim/thrimshim/main.py +++ b/thrimshim/thrimshim/main.py @@ -90,6 +90,13 @@ def authenticate(f): def test(editor=None): return json.dumps(editor) +# To make nginx proxying simpler, we want to allow /metrics/* to work +@app.route('/metrics/') +@request_stats +def metrics_with_trailing(trailing): + """Expose Prometheus metrics.""" + return prometheus_client.generate_latest() + @app.route('/metrics') @request_stats def metrics():