Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Monitoring django rest framework api on production server

I have an API created using django rest framework in a Linode server. Now, I want to check the number and the response code of each request, I want to get stats for my api. How can I do it? thankyou so much.

like image 864
Danna Castro Avatar asked Dec 14 '15 19:12

Danna Castro


3 Answers

DRF Tracking is utilities to track requests to DRF API views, it may be good fit for you:

install: pip install drf-tracking

apply migrations: python manage.py migrate

add the following to you API views:

 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 an other alternative Django Analytics if you want to have more than choice.

like image 147
Dhia Avatar answered Sep 20 '22 15:09

Dhia


So the simplest way to get started is to check your webserver's access logs. That should give you the number of requests in and responses out, including status code. If you want more feature-full statistics as well as monitoring and alerting, you may want to look into something like NewRelic.

like image 44
mmcclannahan Avatar answered Sep 18 '22 15:09

mmcclannahan


maybe you could use drf-tracking

like image 42
marco carminati Avatar answered Sep 19 '22 15:09

marco carminati