django-prometheus icon indicating copy to clipboard operation
django-prometheus copied to clipboard

Add config in settings to allow using a prefix for metrics

Open mrtaalebi opened this issue 3 years ago • 2 comments

Hi!

I think adding a prefix to metrics of each app/service is a good practice. Especially in bigger companies that have a Prometheus server, monitoring a lot of apps/services. So why not implement it in the library?

I will submit a PR upon approval. And I think a good implementation would be to have something like this in Django settings and then using it as the prefix of exposed metrics (if present ofc).

django_settings:

DJANGO_PROMETHEUS = {
    'METRICS_PREFIX': 'sth_sth_sth',
}

mrtaalebi avatar Apr 13 '21 14:04 mrtaalebi

this already exists... see PROMETHEUS_METRIC_NAMESPACE it does that using the python-client namespace property added to metrics. https://github.com/prometheus/client_python/blob/ccb8395265e3745098f3aef1b5ad34ac869e0bc7/README.md#process-collector

asherf avatar Apr 13 '21 14:04 asherf

Well, my bad :)) I also followed your link and there was no explicit reference to this setting. Maybe adding it to the documentation of this repo helps.

mrtaalebi avatar Apr 13 '21 15:04 mrtaalebi