Set Up New Relic for a Django project

1. Setup a New Relic account:

http://newrelic.com/signup

2. Install the newrelic app

pip install newrelic

2. Copy your license key

4. Create the new relic config file:

newrelic-admin generate-config LICENSE-KEY newrelic.ini

5. Edit the newrelic.ini file to give your application a name:

app_name = My Python Application

6. Update wsgi.py:

import newrelic.agent
import os

newrelic.agent.initialize('/home/username/path/to/myproject/newrelic.ini')

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myproject.settings") 

from django.core.wsgi import get_wsgi_application 

application = get_wsgi_application()
application = newrelic.agent.wsgi_application()(application)

6. Verify it’s working:

newrelic-admin validate-config newrelic.ini

7. Start making request to the dev server and log into your New Relic account to see the data!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s