Skip to main content

🚀 Easily Monitor Your Django App with New Relic

54 views 2 min read read

Integrating New Relic with Django is incredibly simple! Learn how to set up monitoring, track performance, and debug issues in real time.

Why Monitor Your Django App?

Performance issues and unexpected errors can harm your Django app's user experience. With New Relic , you can track server health, database queries, and request performance in real time.

Step 1: Install New Relic

Start by installing the New Relic Python agent in your Django project:

pip install newrelic

Step 2: Generate Configuration

Run the following command to create a newrelic.ini config file:

newrelic-admin generate-config YOUR_LICENSE_KEY newrelic.ini

Replace YOUR_LICENSE_KEY with your New Relic account license key.

Step 3: Configure New Relic

Edit the newrelic.ini file and set the app name and license key :

app_name = MyDjangoApp
license_key = YOUR_LICENSE_KEY
monitor_mode = true

Step 4: Run Django with New Relic

Start your Django app with New Relic monitoring:

NEW_RELIC_CONFIG_FILE=newrelic.ini newrelic-admin run-program python manage.py runserver

Step 5: Deploy in Production

If you're using Gunicorn , start your app like this:

NEW_RELIC_CONFIG_FILE=newrelic.ini newrelic-admin run-program gunicorn myproject.wsgi:application --bind 0.0.0.0:8000

Step 6: Check Your New Relic Dashboard

Visit New Relic and check your app’s performance, errors, and database queries in real time!

Conclusion

Setting up New Relic in Django is surprisingly easy and gives you powerful insights into your application's performance. Start monitoring today! 🚀