Monitoring django rest framework api on production server

I have an API created using the django rest platform on a Linode server. Now I want to check the number and response code of each request, I want to get statistics for my api. How can I do it? Thank you very much.

+6
source share
3 answers

DRF tracking is a utility for tracking requests for DRF API submissions, this may come in handy for you:

install: pip install drf-tracking

apply migrations: python manage.py migrate

add the following kinds of APIs:

  from rest_framework import generics from rest_framework_tracking.mixins import LoggingMixin class LoggingView(LoggingMixin, generics.GenericAPIView): def get(self, request): return Response('with logging') 

There is also another alternative to Django Analytics if you want to have more choices.

+9
source

So, the easiest way to get started is to check the web server access logs. This should give you a number of requests and responses, including a status code. If you want more full-featured statistics, as well as monitoring and alerts, you can look into something like NewRelic.

+4
source

maybe you could use drf-tracking

+2
source

All Articles