Use New Relic Django projects

All good health!

Who has used New Relic Django projects, please tell us more about how to use it =) (step by step)

The new user at registration of given Gold mode for 14 days, but to use them does not work (in the panel do not receive any data). Spent a couple of evenings to add: found this Libu +docks on the New Relic site

PS: raised for Python 2.7, virtualenv, Django 1.5.5 Ubuntu 12.04. The project is run in conjunction with Nginx & uWSGI

October 3rd 19 at 02:08
3 answers
October 3rd 19 at 02:10

Instructions for installing Python agent https://docs.newrelic.com/docs/python/python-agent-installation

Instructions for configuring it on uwsgi https://docs.newrelic.com/docs/python/python-agent-and-uwsgi

Just before the command to start uwsgi like to add "newrelic-admin run-program" and specify the path to the configuration:

NEW_RELIC_CONFIG_FILE=newrelic.ini newrelic-admin run-program uwsgi --socket /tmp/uwsgi.sock --single-interpreter --enable-threads wsgi.py

Come on sequentially. 1. generate newrelic.ini: newrelic-admin generate-config newrelic bbf3ab09ff.ini 2. modified project/wsgi.py: 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) 3. added to /etc/uwsgi/apps-available/myapp.ini last line [uwsgi] workers = 2 processes = 2 autoload = true env = DJANGO_SETTINGS_MODULE=project.settings module = project.wsgi log-date = true chdir = /home/www/%n/ virtualenv = /home/www/%n/.env/ pythonpath = /home/www/%n/ harakiri = 30 no-orphans = true reload-mercy = 8 max-requests = 5000 eval = import newrelic.agent, wsgi; application = newrelic.agent.wsgi_application()(wsgi.application) And... nothing happened :( What could be the problem? Maybe you need to run a separate uWSGI service? - jean_Reynol commented on October 3rd 19 at 02:13
And how it now to delete? =) - jean_Reynol commented on October 3rd 19 at 02:16
October 3rd 19 at 02:12

Come on sequentially.

1. generate newrelic.ini:

newrelic-admin generate-config newrelic bbf3ab09ff.ini

2. modified project/wsgi.py:
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)

3. added to /etc/uwsgi/apps-available/myapp.ini last line
[uwsgi]
workers = 2
processes = 2
autoload = true

env = DJANGO_SETTINGS_MODULE=project.settings
module = project.wsgi

log-date = true

chdir = /home/www/%n/
virtualenv = /home/www/%n/.env/
pythonpath = /home/www/%n/

harakiri = 30
no-orphans = true
reload-mercy = 8
max-requests = 5000

eval = import newrelic.agent, wsgi; application = newrelic.agent.wsgi_application()(wsgi.application)


And... nothing happened :(
What could be the problem? Maybe you need to run a separate uWSGI service?

PS: if you run the newrelic-admin validate-config newrelic.ini, all the rules - requests go to the test project.

October 3rd 19 at 02:14

Here is the config to run Django project with New Relic through the supervisor:

[program:django]
user = www-data
command = newrelic-admin run-program /usr/local/bin/uwsgi
 --module 'project.wsgi:application'
 --socket /tmp/%(program_name)s_%(process_num)02d.sock
 --processes 1
 --threads 6
the --single-interpreter
--enable-threads
--vacuum
--need-app
--log-x-forwarded-for
 --buffer-size 32768
 --post-buffering 65536
--disable-logging

environment =
NEW_RELIC_CONFIG_FILE="/etc/project/newrelic.ini",
 DJANGO_SETTINGS_MODULE="project.settings"

Find more questions by tags PythonDjango