- Get real-time metrics on API usage, errors, and performance
- Track API adoption and usage by individual consumers
- Log and inspect API requests and responses
- Capture application logs, correlated with API requests
- Monitor uptime and set up custom alerts
Create app
To get started, create a new app in the Apitally dashboard and select as your framework.
prod
and dev
) for your app, or simply accept the defaults.
Take a note of the client ID displayed after submitting. You will need it in the next step.
Add middleware
Next, install the Apitally SDK in your project with the extra.MIDDLEWARE
list in your Django settings.
Then configure the Apitally middleware by adding APITALLY_MIDDLEWARE
to your settings file and including the client_id
for your app.
You’ll find the client_id
on the Setup instructions page for your app in the Apitally dashboard, which is displayed immediately after creating the app.
If you’re using uWSGI to serve your app in production, make sure to run it with the
--enable-threads
and --lazy-apps
options. Otherwise the Apitally client won’t work correctly.At this point the basic setup for your application is complete and you will start seeing data in the Apitally dashboard.
Identify consumers
To analyze and filter API traffic by consumers, you can associate requests with consumer identifiers in your application. In most cases, use the authenticated identity to identify the consumer. The identifier should be a string, such as a username, email address, or any other unique identifier. Optionally, you can also provide a display name and group for each consumer. To associate requests with consumers, provide a callback function in the middleware settings that takes aHttpRequest
object as an argument and returns a consumer identifier, an ApitallyConsumer
object or None
.
The Consumers dashboard now shows all consumers that have made requests to your application. You can also filter other dashboards by consumer.
Configure request logging
Logging of individual requests and responses is disabled by default to protect potentially sensitive data. If you enable it, you can configure in detail what parts of the request and response should be logged. You can also mask sensitive information (e.g. in headers) and exclude certain requests from logging. The SDK applies default masking rules for common sensitive headers, query parameters and request/response body fields.The Request logs dashboard now shows individual requests handled by your application. You can filter, search, and inspect them in detail.
Advanced settings
- By default, only DRF endpoints are included in Apitally. To also include regular Django views you can set
include_django_views
toTrue
. Useful if your API includes endpoints not implemented using DRF. - To limit Apitally to specific parts of a large monolithic application, set the
urlconfs
parameter to a list of Django URL configuration modules you’d like to include.
Known issues
- When running Django with Gunicorn, the option
preload_app
must be set toFalse
. Otherwise, the Apitally client will not work correctly.