Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design. Librato’s Django instrumentation gives Python web developers access to essential performance and health metrics concerning their Django web applications.



You’ll need a Django-based web application running on Python 2.7 or 3.

Create the Integration

To begin, navigate to the Integrations page. Select Django Monitoring to add your Django integration.


Provide a unique name for your your integration and click save.


A configuration snippet will appear containing basic instructions for instrumenting your Django application. Take note of the librato-config command with your Librato integration credentials:


Follow the steps below for each server your web application is running on.

Django Instrumentation

Optionally create a Python virtual environment, to isolate the instrumentation to your Django web application. The following commands show how to create and activate a virtual environment called ‘django-venv’. Replace ‘django-venv’ with a name you prefer.

$ virtualenv django-venv
$ source django-venv/bin/activate

Install and configure the librato-python-web instrumentation using the commands provided in the integration settings.

$ pip install librato-python-web
$ librato-config --app-id django-prod-1 \
    --user --api-token XXXXXXXXXXXX

The librato-config utility will create an agent-conf.json configuration file on your file system.

$ cat agent-conf.json
   "integration": "django",
   "metrics_hostname": "",
   "hostname": "localhost",
   "stop": false,
   "app_id": "django-prod-1",
   "no_aggregate_counters": false,
   "pidfile": "/var/run/",
   "flush_interval": 10000,
   "daemonize": false,
   "user": "",
   "expire": 0,
   "api_token": “XXXXXXXXXXXX”,
   "debug": false,
   "pct": 95,
   "port": 8142,
   "restart": false

There is no need to modify the default values unless the StatsD port happens to be used already. Simply replace the port value with an ephemeral port that is not in use.

Modify your startup script by prefixing the librato-launch command to your regular command arguments. The typical command to run an application using the Django shell would look as follows.

$ librato-launch python runserver

Deploy your updated startup script and stop any running instances of your web application.

Start your web application from the folder containing the configuration file (the configuration file can be relocated as necessary). The librato-launch utility will run a bundled version of StatsD to aggregate and report metrics to Librato. We use a non-standard port (8142) by default to avoid conflicting with already running StatsD instances.

Django Workspace

You should now be able to see django.* metrics in your Librato account. Navigate to Spaces to view your Django dashboard.