How To Use New Relic APM With Magento 2
Monitoring your Magento 2 store performance is crucial for maintaining speed and reliability.
With New Relic APM (Application Performance Monitoring), you can track real-time metrics, detect slow PHP transactions, and analyze server performance easily.
In this guide, you’ll learn how to set up New Relic APM with Magento 2 using the official installation script.
👉 If you haven’t installed New Relic APM on your server yet, follow this guide first:
How to Install New Relic APM on Ubuntu
Steps To Use New Relic APM With Magento 2
Step 1: Log in to New Relic and Select PHP Agent
- Go to https://one.newrelic.com/
- In the left sidebar, select APM & Services → Add Data
- Choose PHP as your data source
- You’ll see a screen like this:
- It shows a script to install the PHP agent automatically using your account credentials.
curl -Ls https://download.newrelic.com/install/newrelic-cli/scripts/install.sh | bash && sudo NEW_RELIC_API_KEY=NRAK-XXXXXXXXXXXXXXXXXXXXXXXX NEW_RELIC_ACCOUNT_ID=1234567 /usr/local/bin/newrelic install -n php-agent-installer

This command installs the New Relic CLI, sets up the PHP Agent, and automatically links it to your New Relic account.
💡 Note: Replace NEW_RELIC_API_KEY and NEW_RELIC_ACCOUNT_ID with the values provided in your New Relic setup screen.
Then, run this script on your server.

Step 2: Verify Installation
After the script finishes running, verify that the agent is loaded successfully.
Run this command:
php -i | grep newrelic
If you see output like:
newrelic.enabled => true => true
newrelic.license => YOUR_LICENSE_KEY => YOUR_LICENSE_KEY
newrelic.appname => YOUR_APPNAME => YOUR_APPNAME
The New Relic PHP agent is active and ready.
Step 3: Visit Your Magento 2 Store
Now visit your Magento 2 storefront and perform some actions — open product pages, add to cart, or checkout.
This will generate PHP transactions that the New Relic agent can capture.
Then, return to your New Relic dashboard:
Go to APM & Services → Applications
You should see a new app named something like Magento 2 Store showing live metrics:
- Response time
- Throughput (requests/minute)
- Slow transactions
- Database performance
If nothing appears after 5–10 minutes, check your logs:
tail -f /var/log/newrelic/php_agent.log
Step 4: Monitor Magento 2 Performance
After successful setup, you’ll start seeing detailed performance insights in New Relic:
- Application Response Time: Identify bottlenecks
- Transaction Traces: Detect slow code paths
- Database Queries: Analyze Magento SQL performance
- Error Analytics: Debug PHP exceptions and issues
You can also create custom dashboards to track checkout performance, API calls, or cron jobs.
Integrating New Relic APM with Magento 2 is one of the easiest and most effective ways to gain real-time visibility into your store’s performance.
By following this setup guide, you can monitor slow transactions, optimize PHP execution, and ensure your Magento 2 website stays fast and reliable under heavy load.
With the New Relic dashboard, you can quickly identify bottlenecks, improve response times, and deliver a smoother shopping experience to your customers.