CherryPy¶
CherryPy is a high-level Python Web framework that encourages rapid development and clean, pragmatic design. Librato’s CherryPy instrumentation gives Python web developers access to essential performance and health metrics concerning their CherryPy web applications.
Installation¶
Prequisites¶
You’ll need a CherryPy-based web application running on Python 2.7 or 3.
Create the Integration¶
To begin, navigate to the Integrations page. Select CherryPy Monitoring to add your CherryPy integration.
Provide a unique name for your your integration and click save.
A configuration snippet will appear containing basic instructions for instrumenting your CherryPy 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.
CherryPy Instrumentation¶
Optionally create a Python virtual environment, to isolate the instrumentation to your CherryPy web application. The following commands show how to create and activate a virtual environment called ‘cherrypy-venv’. Replace ‘cherrypy-venv’ with a name you prefer.
$ virtualenv cherrypy-venv
$ source cherrypy-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 cherrypy-prod-1 --integration=cherrypy \
--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": "cherrypy",
"metrics_hostname": "metrics-api.librato.com",
"hostname": "localhost",
"stop": false,
"app_id": "cherrypy-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 CherryPy 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.
CherryPy Workspace¶
You should now be able to see cherrypy.*
metrics in your Librato account. Navigate to Spaces to view your
CherryPy dashboard.