Reputation: 428
I have a nodeJS app which need to report apm data to new relic. package.json contains newrelic package with latest version. when I start the application using pm2 start -- node app.js using user-data script, the newrelic logs say the following:
{"v":0,"level":30,"name":"newrelic","hostname":"ip","pid":3413,"time":"2022-04-19T04:51:27.794Z","msg":"Using New Relic for Node.js. Agent version: 8.9.1; Node version: v12.20.2."}
{"v":0,"level":30,"name":"newrelic","hostname":"ip","pid":3413,"time":"2022-04-19T04:51:27.950Z","msg":"Using LegacyContextManager"}
{"v":0,"level":30,"name":"newrelic","hostname":"ip","pid":3413,"time":"2022-04-19T04:51:28.029Z","msg":"Agent state changed from stopped to starting."}
{"v":0,"level":30,"name":"newrelic","hostname":"ip","pid":3413,"time":"2022-04-19T04:51:28.046Z","msg":"Starting New Relic for Node.js connection process."}
{"v":0,"level":30,"name":"newrelic","hostname":"ip","pid":3413,"time":"2022-04-19T04:51:28.046Z","msg":"Agent state changed from starting to connecting."}
{"v":0,"level":40,"name":"newrelic","hostname":"ip","pid":3413,"time":"2022-04-19T04:51:32.215Z","msg":"Your license key appears to be invalid. Reattempting connection to New Relic. If the problem persists, please contact [email protected]. (status code 401)","component":"collector_api"}
{"v":0,"level":40,"name":"newrelic","hostname":"ip","pid":3413,"time":"2022-04-19T04:51:47.314Z","msg":"Your license key appears to be invalid. Reattempting connection to New Relic. If the problem persists, please contact [email protected]. (status code 401)","component":"collector_api"}
{"v":0,"level":40,"name":"newrelic","hostname":"ip","pid":3413,"time":"2022-04-19T04:52:02.612Z","msg":"Your license key appears to be invalid. Reattempting connection to New Relic. If the problem persists, please contact [email protected]. (status code 401)","component":"collector_api"}
{"v":0,"level":40,"name":"newrelic","hostname":"ip","pid":3413,"time":"2022-04-19T04:52:32.739Z","msg":"Your license key appears to be invalid. Reattempting connection to New Relic. If the problem persists, please contact [email protected]. (status code 401)","component":"collector_api"}
{"v":0,"level":40,"name":"newrelic","hostname":"ip","pid":3413,"time":"2022-04-19T04:52:32.739Z","msg":"No connection has been established to New Relic after 4 attempts.","component":"collector_api"}
{"v":0,"level":40,"name":"newrelic","hostname":"ip","pid":3413,"time":"2022-04-19T04:53:32.835Z","msg":"Your license key appears to be invalid. Reattempting connection to New Relic. If the problem persists, please contact [email protected]. (status code 401)","component":"collector_api"}
I tried restarting the app in my userdata script but still the same issue.
But if I manually ssh and restart the app using pm2 restart all, it starts reporting the data, so I am not sure what is going wring here.
{"v":0,"level":30,"name":"newrelic","hostname":"ip","pid":5891,"time":"2022-04-19T04:58:50.799Z","msg":"Using New Relic for Node.js. Agent version: 8.9.1; Node version: v12.20.2."}
{"v":0,"level":30,"name":"newrelic","hostname":"ip","pid":5891,"time":"2022-04-19T04:58:50.882Z","msg":"Using LegacyContextManager"}
{"v":0,"level":30,"name":"newrelic","hostname":"ip","pid":5891,"time":"2022-04-19T04:58:50.939Z","msg":"Agent state changed from stopped to starting."}
{"v":0,"level":30,"name":"newrelic","hostname":"ip","pid":5891,"time":"2022-04-19T04:58:50.950Z","msg":"Starting New Relic for Node.js connection process."}
{"v":0,"level":30,"name":"newrelic","hostname":"ip","pid":5891,"time":"2022-04-19T04:58:50.950Z","msg":"Agent state changed from starting to connecting."}
{"v":0,"level":30,"name":"newrelic","hostname":"ip","pid":5891,"time":"2022-04-19T04:58:53.383Z","msg":"Agent state changed from connecting to connected."}
{"v":0,"level":30,"name":"newrelic","hostname":"ip","pid":5891,"time":"2022-04-19T04:58:53.383Z","msg":"Connected to collector-007.newrelic.com:443 with agent run ID BUI00nn_ttd8ABR9KGwzQC9iXkHQAAgBAAAnIQEAABcDAgQGywUvAwAFOC45LjEAEWlwLTEwLTIwMS0xNTEtMTMxACxyYXB0b3ItbWFuYWdlbWVudC11aS1QcmVQcm9kdWN0aW9uIChOb2RlLmpzKQ.","component":"collector_api"}
{"v":0,"level":30,"name":"newrelic","hostname":"ip","pid":5891,"time":"2022-04-19T04:58:53.383Z","msg":"Reporting to: https://rpm.newrelic.com/accounts/111111/applications/22222222","component":"collector_api"}
{"v":0,"level":30,"name":"newrelic","hostname":"ip","pid":5891,"time":"2022-04-19T04:58:53.385Z","msg":"Valid event_harvest_config received. Updating harvest cycles. {\"report_period_ms\":5000,\"harvest_limits\":{\"error_event_data\":8,\"log_event_data\":833,\"analytic_event_data\":833,\"custom_event_data\":83}}"}
{"v":0,"level":30,"name":"newrelic","hostname":"ip","pid":5891,"time":"2022-04-19T04:58:53.388Z","msg":"Agent state changed from connected to started."}
{"v":0,"level":30,"name":"newrelic","hostname":"ip","pid":5891,"time":"2022-04-19T04:58:54.390Z","msg":"Starting initial 1000ms harvest."}
The error message in the initial logs is quite misleading because restarting the app manually starts reporting the data, hence license key isn't the issue.
Need help in resolving this issue without a manual restart.
Upvotes: 1
Views: 1288
Reputation: 2186
Check if you copied the correct licence key
I was copying the license key from the wrong place. I should have copied the license key from the Account settings -> API keys -> Licence
page
Upvotes: 0