Skip to content

Commit

Permalink
feat: Add prometheus monitoring to django app
Browse files Browse the repository at this point in the history
  • Loading branch information
Gowtham1729 committed Nov 8, 2023
1 parent 1f3afa0 commit 0554907
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 3 deletions.
5 changes: 4 additions & 1 deletion applications/backend/django_server/django_server/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
INSTALLED_APPS = [
"rest_framework",
"corsheaders",
"django_prometheus",
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
Expand All @@ -65,6 +66,7 @@
]

MIDDLEWARE = [
"django_prometheus.middleware.PrometheusBeforeMiddleware",
"django.middleware.security.SecurityMiddleware",
"corsheaders.middleware.CorsMiddleware",
"whitenoise.middleware.WhiteNoiseMiddleware",
Expand All @@ -74,6 +76,7 @@
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
"django_prometheus.middleware.PrometheusAfterMiddleware",
]

ROOT_URLCONF = "django_server.urls"
Expand Down Expand Up @@ -102,7 +105,7 @@

DATABASES = {
"default": {
"ENGINE": "django.db.backends.postgresql",
"ENGINE": "django_prometheus.db.backends.postgresql",
"NAME": DB_NAME,
"USER": DB_USER,
"HOST": DB_HOST,
Expand Down
3 changes: 2 additions & 1 deletion applications/backend/django_server/django_server/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

urlpatterns = [
path("api/admin/", admin.site.urls),
path("api/news/", include("news.urls")),
path("healthz/", views.healthz, name="healthz"),
path("", include("django_prometheus.urls")),
path("api/news/", include("news.urls")),
]
30 changes: 29 additions & 1 deletion applications/backend/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions applications/backend/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ djangorestframework = "^3.14.0"
markdown = "^3.5.1"
django-filter = "^23.3"
django-cors-headers = "^4.3.0"
django-prometheus = "^2.3.1"
prometheus-client = "^0.18.0"

[tool.poetry.group.dev.dependencies]
isort = "^5.12.0"
Expand Down

0 comments on commit 0554907

Please sign in to comment.