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.
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.
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.
maybe you could use drf-tracking
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With