Reputation: 299
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.
Upvotes: 12
Views: 8050
Reputation: 501
Apitally may also be a good fit here.
It's an API monitoring & analytics tool with an integration for Django REST Framework (DRF). It captures request and response metadata and provides a simple dashboard with various API metrics & insights, including number of requests, error rates, response times, payload sizes, etc.
There is a specific setup guide for Django REST Framework that you can follow to get started. The basic steps are:
pip install "apitally[django_rest_framework]"
MIDDLEWARE = [
"apitally.django.ApitallyMiddleware",
# Other middleware ...
]
APITALLY_MIDDLEWARE = {
"client_id": "your-client-id",
"env": "dev", # or "prod" etc.
}
The dashboard looks like this:
Disclaimer: I'm the author of Apitally.
Upvotes: 1
Reputation: 1080
Its fork is available here drf-api-tracking.
It defines itself as
Silky smooth profiling for Django: a live profiling and inspection tool for the Django framework. Silk intercepts and stores HTTP requests and database queries before presenting them in a user interface for further inspection
image source: jazzband/django-silk github repository
Upvotes: 0
Reputation: 10609
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.
Upvotes: 15
Reputation: 1748
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.
Upvotes: 5