From 907c85d85dff0e54abf61e3687c423d96c48f246 Mon Sep 17 00:00:00 2001 From: Minei3oat Date: Sun, 28 Sep 2025 21:09:25 +0200 Subject: [PATCH] Add Content-Type=plain/text for metrics endpoint Without the content type, prometheus will reject the metrics if no `fallback_scrape_protocol` is specified. https://prometheus.io/docs/prometheus/3.0/migration/#scrape-protocols https://prometheus.io/docs/instrumenting/exposition_formats/#text-based-format --- backend/routers/nfregex.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/backend/routers/nfregex.py b/backend/routers/nfregex.py index f3a4498..66bc2d0 100644 --- a/backend/routers/nfregex.py +++ b/backend/routers/nfregex.py @@ -1,7 +1,8 @@ from base64 import b64decode import secrets import sqlite3 -from fastapi import APIRouter, Response, HTTPException +from fastapi import APIRouter, HTTPException +from fastapi.responses import PlainTextResponse from pydantic import BaseModel from modules.nfregex.nftables import FiregexTables from modules.nfregex.firewall import STATUS, FirewallManager @@ -332,7 +333,7 @@ async def add_new_service(form: ServiceAddForm): await refresh_frontend() return {'status': 'ok', 'service_id': srv_id} -@app.get('/metrics', response_class = Response) +@app.get('/metrics', response_class = PlainTextResponse) async def metrics(): """Aggregate metrics""" stats = db.query("""