From 3291e404d42467aa8a94b73a6736be76a76f9c17 Mon Sep 17 00:00:00 2001 From: lagertonne Date: Wed, 6 Nov 2024 22:21:32 +0100 Subject: [PATCH] WIP: Add the django standard metrics --- core/core/settings.py | 5 +++++ core/core/urls.py | 1 + core/requirements.prod.txt | 2 ++ 3 files changed, 8 insertions(+) diff --git a/core/core/settings.py b/core/core/settings.py index db23180..124fcad 100644 --- a/core/core/settings.py +++ b/core/core/settings.py @@ -50,6 +50,7 @@ INSTALLED_APPS = [ 'django.contrib.messages', 'django.contrib.staticfiles', 'django_extensions', + 'django_prometheus', 'rest_framework', 'knox', 'drf_yasg', @@ -85,6 +86,7 @@ SWAGGER_SETTINGS = { } MIDDLEWARE = [ + 'django_prometheus.middleware.PrometheusBeforeMiddleware', 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', @@ -92,6 +94,7 @@ MIDDLEWARE = [ 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', + 'django_prometheus.middleware.PrometheusAfterMiddleware', ] ROOT_URLCONF = 'core.urls' @@ -210,4 +213,6 @@ CHANNEL_LAYERS = { } +PROMETHEUS_METRIC_NAMESPACE = 'c3lf' + TEST_RUNNER = 'core.test_runner.FastTestRunner' diff --git a/core/core/urls.py b/core/core/urls.py index b0161bb..df6e0d0 100644 --- a/core/core/urls.py +++ b/core/core/urls.py @@ -32,4 +32,5 @@ urlpatterns = [ path('api/2/', include('notify_sessions.api_v2')), path('api/2/', include('authentication.api_v2')), path('api/', get_info), + path('', include('django_prometheus.urls')), ] diff --git a/core/requirements.prod.txt b/core/requirements.prod.txt index 14bdc0f..ee69fe7 100644 --- a/core/requirements.prod.txt +++ b/core/requirements.prod.txt @@ -41,3 +41,5 @@ urllib3==2.1.0 uvicorn==0.24.0.post1 watchfiles==0.21.0 websockets==12.0 +django-prometheus==2.3.1 +prometheus_client==0.21.0