This is a detailed guide showing how to install New Relic's Python agent for application performance monitoring. For simpler install instructions that will work for the majority of Python frameworks (including Django), see the standard installation guide. Read this advanced guide if you cannot use the standard install, or if you want more detailed information about the installation steps.
To use Python or any other agent, as well as the rest of our observability platform, join the New Relic family! Sign up to create your free account in only a few seconds. Then ingest up to 100GB of data for free each month. Forever.
Before you install the Python agent:
- Read and understand the compatibility and requirements.
- Have your New Relic account's license key. (If you don't have one already, sign up for a New Relic account.)
Here's a summary of how to install the Python agent:
- Download and install the Python agent package.
- Create config file.
- Integrate the agent with your app.
- Restart your app.
Download and install the agent package using your preferred procedure. For example:
The config file is the primary method to customize the agent's behavior. You can also use server-side configuration or environment variables.
After you install the package, the
newrelic-admin script will be in the same directory as the Python executable. To create the agent config file, run this command in the Python executable's directory and include your license key:
newrelic-admin generate-config YOUR_LICENSE_KEY newrelic.ini
generate-config command creates the
newrelic.ini config file.
You need to integrate the Python agent with your application so that your app's major functions and web requests are received by the agent. To integrate the Python agent with your app, run the
newrelic-admin script in front of your usual app startup command.
If you use any of the following services, follow these guidelines before continuing to the admin script procedure.
To run the
newrelic-admin script via the command line, place the following in front of your standard app startup command:
- The path to the New Relic config file
newrelic-admin run-programscript command
For example, here are instructions for a Bourne-style shell. You may need to adjust these instructions for a different shell. If you use a Python gunicorn web server and your startup command is:
gunicorn -w 3 wsgi:application
Then use this command:
NEW_RELIC_CONFIG_FILE=newrelic.ini newrelic-admin run-program gunicorn -w 3 wsgi:application
When you finish the integration procedure:
- Restart your app server.
- Wait five minutes.
- View your app's data in APM's Summary page.
If data does not appear after five minutes, follow the troubleshooting procedures.
Here are some suggested next steps after installing the Python agent for your app:
- Explore your data in New Relic One and get comfortable with the standard user interface features.
- Learn about APM's Summary page, the Transactions page, and other performance monitoring features.
- Change your application's name, and use other configuration options.
- Set up custom instrumentation for application activity not monitored by default.
- Configure custom events and custom attributes to collect additional data from your app.
If you need more help, check out these support and learning resources:
- Browse the Explorers Hub to get help from the community and join in discussions.
- Find answers on our sites and learn how to use our support portal.
- Run New Relic Diagnostics, our troubleshooting tool for Linux, Windows, and macOS.
- Review New Relic's data security and licenses documentation.