Skip to content

Commit a4bc3d1

Browse files
committed
django: Replace gunicorn-prometheus-exporter with django-prometheus
Remove the dedicated metrics port (9091) and gunicorn-prometheus-exporter support. With Uvicorn ASGI workers, the gunicorn exporter's hooks could not populate any metrics (system gauges were empty). Additionally, both exporters shared the same prometheus_client registry, causing django- prometheus metrics to be duplicated on port 9091. django-prometheus serves metrics at /metrics on the application port (8000), so no extra container or service port is needed. The ServiceMonitor now scrapes the django port directly.
1 parent 247aba5 commit a4bc3d1

5 files changed

Lines changed: 2 additions & 21 deletions

File tree

‎charts/django/Chart.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ type: application
1515
# This is the chart version. This version number should be incremented each time you make changes
1616
# to the chart and its templates, including the app version.
1717
# Versions are expected to follow Semantic Versioning (https://semver.org/)
18-
version: 0.8.2
18+
version: 0.8.3
1919

2020
# This is the version number of the application being deployed. This version number should be
2121
# incremented each time you make changes to the application. Versions are not expected to

‎charts/django/templates/deployment.yaml‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,6 @@ spec:
7878
- name: django
7979
containerPort: {{ .Values.image.containerPort }}
8080
protocol: TCP
81-
{{- if .Values.metrics.enabled }}
82-
- name: metrics
83-
containerPort: {{ .Values.metrics.port | default 9091 }}
84-
protocol: TCP
85-
{{- end }}
8681
{{- with .Values.probes }}
8782
{{- if .liveness.enabled }}
8883
livenessProbe:

‎charts/django/templates/service.yaml‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,6 @@ spec:
1717
protocol: TCP
1818
name: caddy
1919
{{- end }}
20-
{{- if .Values.metrics.enabled }}
21-
- name: metrics
22-
port: {{ .Values.metrics.port | default 9091 }}
23-
targetPort: metrics
24-
protocol: TCP
25-
{{- end }}
2620
selector:
2721
{{- include "django.labels" . | nindent 4 }}
2822
app.kubernetes.io/component: {{ include "django.fullname" . }}

‎charts/django/templates/servicemonitor.yaml‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,7 @@ spec:
1010
matchLabels:
1111
{{- include "django.selectorLabels" . | nindent 6 }}
1212
endpoints:
13-
- port: metrics
14-
path: /metrics
15-
interval: {{ .Values.metrics.serviceMonitor.interval | default "30s" }}
16-
{{- if .Values.metrics.djangoMetrics.enabled }}
1713
- port: django
1814
path: /metrics
1915
interval: {{ .Values.metrics.serviceMonitor.interval | default "30s" }}
20-
{{- end }}
2116
{{- end }}

‎charts/django/values.yaml‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,12 @@ service:
6262
type: ClusterIP
6363
port: 8000
6464

65-
# Prometheus metrics (e.g. gunicorn-prometheus-exporter)
65+
# Prometheus metrics (django-prometheus)
6666
metrics:
6767
enabled: false
68-
port: 9091
6968
serviceMonitor:
7069
enabled: false
7170
interval: 30s
72-
djangoMetrics:
73-
enabled: false
7471

7572
# Caddy Settings (static + media files serving)
7673
proxy:

0 commit comments

Comments
 (0)