oncall-engine/engine/apps/metrics_exporter/views.py
Yulya Artyukhina 15ef692009
OnCall prometheus metrics exporter (#1605)
# What this PR does
Add OnCall prometheus metrics exporter

## Which issue(s) this PR fixes

## Checklist

- [x] Tests updated
- [ ] Documentation added
- [ ] `CHANGELOG.md` updated

---------

Co-authored-by: Joey Orlando <joey.orlando@grafana.com>
Co-authored-by: Matias Bordese <mbordese@gmail.com>
2023-05-25 18:26:13 +00:00

11 lines
424 B
Python

from django.http import HttpResponse
from prometheus_client import generate_latest
from rest_framework.views import APIView
from .metrics_collectors import application_metrics_registry
class MetricsExporterView(APIView):
def get(self, request):
result = generate_latest(application_metrics_registry).decode("utf-8")
return HttpResponse(result, content_type="text/plain; version=0.0.4; charset=utf-8")