aws-amplify / aws-amplify/amplify-hosting
New Relic Agent not working on AWS
- Dominant language
- Dockerfile
- Stars
- 481
- Forks
- 123
- PR merge metrics
- No merged PRs in 30d
Description
### Before opening, please confirm:
- [X] I have checked to see if my question is addressed in the [FAQ](https://github.com/aws-amplify/amplify-hosting/blob/master/FAQ.md).
- [X] I have [searched for duplicate or closed issues](https://github.com/aws-amplify/amplify-hosting/issues?q=is%3Aissue+).
- [X] I have read the guide for [submitting bug reports](https://github.com/aws-amplify/amplify-hosting/blob/master/CONTRIBUTING.md).
- [X] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
- [X] I have removed any sensitive information from my code snippets and submission.
### App Id
arn:aws:amplify:us-east-1:742781839140:apps/ds59ukyq97w6a
### AWS Region
us-east-1
### Amplify Hosting feature
SSR
### Describe the bug
I´m using a NextJS application that uses New Relic NextJS Agent as an application monitoring.
The agent uses a node module named @newrelic/next that loads before the application start using the command below:
`NODE_OPTIONS='-r @newrelic/next' next start`
When executing on the local machine, all metrics are collected as exepected. On Amplify no metrics, logs or anything are been colleccted.
Reference: https://github.com/newrelic/newrelic-node-nextjs
### Expected behavior
Get APM, logs, Browser and other metrics on New Relic Application using the agent installed
### Reproduction steps
1. Create an nextjs sample app
2. Install module `npm install @newrelic/next`
3. Load module on start script using `NODE_OPTIONS='-r @newrelic/next' next start`
4. Instrument the application [https://github.com/newrelic/newrelic-node-nextjs](url)
5. Check logs on New Relic Application
### Build Settings
```yaml
#package.json
{
"name": "hotel",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "set NODE_OPTIONS='-r @newrelic/next' && next dev",
"build": "next build",
"start": "NODE_OPTIONS='-r @newrelic/next' next start",
"lint": "next lint"
}
}
#amplify.yml
version: 1
frontend:
phases:
preBuild:
commands:
- yarn install
build:
commands:
- cp .env.$BUILD_ENV .env
- rm .env.*
- rm newrelic.js
- sed -i "s//$NEWRELIC_KEY/g" newrelic-template.js
- cp newrelic-template.js newrelic.js
- yarn run build
artifacts:
baseDirectory: .next
files:
- '**/*'
cache:
paths:
- node_modules/**/*
```
### Log output
```
# Put your logs below this line
```
### Additional information
_No response_
Contributor guide
Research direction
Start with the package.json start command and amplify.yml build settings, then reproduce the SSR deployment using NODE_OPTIONS='-r @newrelic/next' and the linked New Relic Next.js instrumentation guide. Compare local and Amplify behavior in the deployment logs; done means the deployed application reports APM, logs, Browser data, and other expected metrics.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, nextjs, node.js
- Domain
- backend, cloud
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100