File tree Expand file tree Collapse file tree 2 files changed +6
-5
lines changed Expand file tree Collapse file tree 2 files changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -115,7 +115,8 @@ def ExportToDjangoView(request):
115
115
116
116
You can use django_prometheus.urls to map /metrics to this view.
117
117
"""
118
- if "prometheus_multiproc_dir" in os .environ :
118
+ if ("PROMETHEUS_MULTIPROC_DIR" in os .environ
119
+ or "prometheus_multiproc_dir" in os .environ ):
119
120
registry = prometheus_client .CollectorRegistry ()
120
121
multiprocess .MultiProcessCollector (registry )
121
122
else :
Original file line number Diff line number Diff line change @@ -78,22 +78,22 @@ targets as you have workers, using each port separately.
78
78
79
79
This approach requires the application to be loaded into each child process.
80
80
uWSGI and Gunicorn typically load the application into the master process before forking the child processes.
81
- Set the [ lazy-apps option] ( https://uwsgi-docs.readthedocs.io/en/latest/Options.html#lazy-apps ) to ` true ` (uWSGI)
81
+ Set the [ lazy-apps option] ( https://uwsgi-docs.readthedocs.io/en/latest/Options.html#lazy-apps ) to ` true ` (uWSGI)
82
82
or the [ preload-app option] ( https://docs.gunicorn.org/en/stable/settings.html#preload-app ) to ` false ` (Gunicorn)
83
- to change this behaviour.
83
+ to change this behaviour.
84
84
85
85
86
86
## Exporting /metrics in a WSGI application with multiple processes globally
87
87
88
88
In some WSGI applications, workers are short lived (less than a minute), so some
89
89
are never scraped by prometheus by default. Prometheus client already provides
90
- a nice system to aggregate them using the env variable: ` prometheus_multiproc_dir `
90
+ a nice system to aggregate them using the env variable: ` PROMETHEUS_MULTIPROC_DIR `
91
91
which will configure the directory where metrics will be stored as files per process.
92
92
93
93
Configuration in uwsgi would look like:
94
94
95
95
``` ini
96
- env = prometheus_multiproc_dir =/path/to/django_metrics
96
+ env = PROMETHEUS_MULTIPROC_DIR =/path/to/django_metrics
97
97
```
98
98
99
99
You can also set this environment variable elsewhere such as in a kubernetes manifest.
You can’t perform that action at this time.
0 commit comments