You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+11-1Lines changed: 11 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -204,6 +204,16 @@ that will export the metrics (replace myapp by your project name).
204
204
205
205
Then we inject the wrapper in settings:
206
206
207
-
```python
207
+
```python
208
208
ROOT_URLCONF="graphite.urls_prometheus_wrapper"
209
209
```
210
+
211
+
## Adding custom labels to middleware (request/response) metrics
212
+
213
+
You can add application specific labels to metrics reported by the django-prometheus middleware.
214
+
This involves extending the classes defined in middleware.py.
215
+
216
+
* Extend the Metrics class and override the `register_metric` method to add the application specific labels.
217
+
* Extend middleware classes, set the metrics_cls class attribute to the the extended metric class and override the label_metric method to attach custom metrics.
218
+
219
+
See implementation example in [the test app](django_prometheus/tests/end2end/testapp/test_middleware_custom_labels.py#L19-L46)
0 commit comments