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



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

Create the Integration

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


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


A configuration snippet will appear containing basic instructions for instrumenting your Flask 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.

Flask Instrumentation

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

$ virtualenv flask-venv
$ source flask-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 flask-prod-1 --integration=flask \
    --user user@librato.com --api-token XXXXXXXXXXXX

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

$ cat agent-conf.json
   "integration": "flask",
   "metrics_hostname": "metrics-api.librato.com",
   "hostname": "localhost",
   "stop": false,
   "app_id": "flask-prod-1",
   "no_aggregate_counters": false,
   "pidfile": "/var/run/solarwinds-python-statsd.pid",
   "flush_interval": 10000,
   "daemonize": false,
   "user": "user@librato.com",
   "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 Flask shell would look as follows.

$ librato-launch python your-server.py

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.

Flask Workspace

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