combine all prometheus metrics in one view
This commit is contained in:
parent
75ff32fc60
commit
60de7857d6
2 changed files with 8 additions and 6 deletions
|
@ -484,10 +484,13 @@ def get_cache_package(request, filetype):
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
||||||
def api_stats_exporter(request):
|
def prometheus_exporter(request):
|
||||||
"""Exports the API metrics for Prometheus"""
|
"""Exports the API metrics for Prometheus"""
|
||||||
|
|
||||||
import prometheus_client
|
import prometheus_client
|
||||||
|
from django_prometheus.exports import ExportToDjangoView
|
||||||
from c3nav.mapdata.metrics import REGISTRY
|
from c3nav.mapdata.metrics import REGISTRY
|
||||||
metrics_page = prometheus_client.generate_latest(REGISTRY)
|
metrics_page = prometheus_client.generate_latest(REGISTRY)
|
||||||
return HttpResponse(metrics_page, content_type=prometheus_client.CONTENT_TYPE_LATEST)
|
response = ExportToDjangoView(request)
|
||||||
|
response.content += metrics_page
|
||||||
|
return response
|
||||||
|
|
|
@ -50,11 +50,10 @@ if settings.SERVE_ANYTHING:
|
||||||
|
|
||||||
if settings.METRICS:
|
if settings.METRICS:
|
||||||
with suppress(ImportError):
|
with suppress(ImportError):
|
||||||
import django_prometheus.urls # noqu
|
import django_prometheus # noqu
|
||||||
from c3nav.mapdata.views import api_stats_exporter
|
from c3nav.mapdata.views import prometheus_exporter
|
||||||
urlpatterns += [
|
urlpatterns += [
|
||||||
path('prometheus/api_metrics', api_stats_exporter),
|
path('prometheus/metrics', prometheus_exporter, name='prometheus-exporter'),
|
||||||
path('prometheus/', include(django_prometheus.urls)),
|
|
||||||
]
|
]
|
||||||
|
|
||||||
if settings.SSO_ENABLED:
|
if settings.SSO_ENABLED:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue