@newrelic/introspector-node

newrelic-introspector-node

Usage no npm install needed!

<script type="module">
  import newrelicIntrospectorNode from 'https://cdn.skypack.dev/@newrelic/introspector-node';
</script>

README

Community Project header

newrelic-introspector-node

This is a CLI tool for discovering instrumentable Node.js applications on a system, retrieving contextual information about them, and automating the install of the New Relic Node agent.

Currently the instrument command only discovers and instruments processes hosted with the PM2 process manager. Support for other process managers will be explored in the future.

Getting Started

> npm i -g @newrelic/introspector-node
> newrelic-introspector-node list
[ 12345 ]

> newrelic-introspector-node introspect --pid 12345
{
  pid: 12345,
  pm_id: 0,
  name: 'server',
  pm_exec_path: '/Users/myuser/node-app/src/server.js',
  pm_cwd: '/Users/myuser/node-app'
}

> newrelic-introspector-node instrument --pid 12345 --licenseKey $NEW_RELIC_LICENSE_KEY --appName "My Node Application"
...
Process instrumented successfully

Instrumenting processes

The instrument command automates several installation steps:

  1. Executes npm install newrelic --save in the working directory of the running application, as provided by PM2.
  2. Sets the NEW_RELIC_APP_NAME and NEW_RELIC_LICENSE_KEY environment variables.
  3. Restarts the application using PM2's restart command, adding -r newrelic to the interpreter args and injecting the newly set environment variables with the --update-env flag.

Instrumentation will survive further restarts with PM2, but may be lost if the application is redeployed or any other actions are taken that revert the changes above.

Support

New Relic hosts and moderates an online forum where customers can interact with New Relic employees as well as other customers to get help and share best practices. Like all official New Relic open source projects, there's a related Community topic in the New Relic Explorers Hub. You can find this project's topic/threads here:

https://discuss.newrelic.com/tags/nodeagent

Contribute

We encourage your contributions to improve newrelic-introspector-node! Keep in mind that when you submit your pull request, you'll need to sign the CLA via the click-through using CLA-Assistant. You only have to sign the CLA one time per project.

If you have any questions, or to execute our corporate CLA (which is required if your contribution is on behalf of a company), drop us an email at opensource@newrelic.com.

A note about vulnerabilities

As noted in our security policy, New Relic is committed to the privacy and security of our customers and their data. We believe that providing coordinated disclosure by security researchers and engaging with the security community are important means to achieve our security goals.

If you believe you have found a security vulnerability in this project or any of New Relic's products or websites, we welcome and greatly appreciate you reporting it to New Relic through HackerOne.

If you would like to contribute to this project, review these guidelines.

License

newrelic-introspector-node is licensed under the Apache 2.0 License.

[The newrelic-introspector-node also uses source code from third-party libraries. You can find full details on which libraries are used and the terms under which they are licensed in the third-party notices document.]