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.
Asked
Active
Viewed 7,242 times
10
3 Answers
15
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.
-
1Hi, thanks you but, I'm using mongodb then, can I get trouble with migrations? – Danna Castro Dec 15 '15 at 00:46
-
In this case I recommend to use [Django-norel](http://django-nonrel.org/) a django support on non-relational databases. – Dhia Jan 29 '16 at 16:20
5
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.

mmcclannahan
- 1,608
- 2
- 15
- 35