diff --git a/helm/templates/web-sm.yaml b/helm/templates/web-sm.yaml index 39970422f..d1cf2a5df 100644 --- a/helm/templates/web-sm.yaml +++ b/helm/templates/web-sm.yaml @@ -18,6 +18,7 @@ spec: name: {{ include "passbook.fullname" . }}-secret-key key: monitoring_username port: http + path: /metrics/ interval: 10s selector: matchLabels: diff --git a/passbook/root/monitoring.py b/passbook/root/monitoring.py index ff9c65a84..05e82a90d 100644 --- a/passbook/root/monitoring.py +++ b/passbook/root/monitoring.py @@ -2,7 +2,7 @@ from base64 import b64encode from django.conf import settings -from django.http import Http404, HttpRequest, HttpResponse +from django.http import HttpRequest, HttpResponse from django.views import View from django_prometheus.exports import ExportToDjangoView @@ -18,6 +18,8 @@ class MetricsView(View): expected = b64encode(str.encode(credentials)).decode() if auth_type != "Basic" or credentials != expected: - raise Http404 + response = HttpResponse(status=401) + response['WWW-Authenticate'] = 'Basic realm="passbook-monitoring"' + return response return ExportToDjangoView(request) diff --git a/passbook/root/urls.py b/passbook/root/urls.py index 2634ebc4e..b9741a118 100644 --- a/passbook/root/urls.py +++ b/passbook/root/urls.py @@ -35,7 +35,7 @@ for _passbook_app in get_apps(): urlpatterns += [ # Administration path("administration/django/", admin.site.urls), - path("metrics", MetricsView.as_view(), name="metrics"), + path("metrics/", MetricsView.as_view(), name="metrics"), ] if settings.DEBUG: