npm install <Node.js-Agent-unzipped-path>/agent_minified
npm install /users/joe/agent_minified
npm install -g <Node.js-Agent-unzipped-path>/agent_minified
npm install -g /users/joe/agent_minified
Create a new file named apminsightnode.json and place it in the directory where you run the application. Add the below code snippet to the file:
{
"licenseKey": "[LICENSE-KEY]",
"appName": "[APPLICATION-NAME]",
"port": "[APPLICATION-PORT]",
"apmHost": "[APM-HOST-NAME]",
"apmPort": "[APM-SSL-PORT]"
}
Example:
{
"licenseKey" : "APMI_ee42094f83dd841d16b9c56796c22b63bef00ac6918f547280947d1f6c2be1ea",
"appName" : "APMInsight_NodeJSapp",
"port" : "3000",
"apmHost": "localhost",
"apmPort": "8443"
}
If you are using proxy, add the below code snippet:
{
"licenseKey": "[LICENSE-KEY]",
"appName": "[APPLICATION-NAME]",
"port": "[APPLICATION-PORT]",
"apmHost": "[APM-HOST-NAME]",
"apmPort": "[APM-SSL-PORT]"
"proxyServerHost": "[PROXY-SERVER]",
"proxyServerPort": "[PROXY-PORT]",
"proxyAuthUser" : "[PROXY-USERNAME]",
"proxyAuthPassword" : "[PROXY-PASSWORD]"
}
You can set configuration values as environment variables using the following keys:
licenseKey - APMINSIGHT_LICENSE_KEYInclude the given code in the first line of your Node.js application start file, before any other require statements.
JavaScript | Code snippet |
---|---|
Common JS | require('apminsight'); |
ECMAScript | import apminsight from 'apminsight'; |
TypeScript | import AgentAPI from apminsight'; AgentAPI.config(); |
Alternatively, you can follow either of the methods given below, which are common across all JavaScript types.
Note: -r is used to pre-load the specified module (apminsight module here) at startup.Only CommonJS modules support -r. Use --import to pre-load a TypeScript or ECMAScript module.
Note: We highly recommend downloading the latest version of the APM Insight Node.js agent. However, if you need to download agent versions below 4.0.0 for any specific reason, please refer to the steps provided below.
To install APM Insight Node.js agent versions 1.7.2 to versons below 4.0.0, follow the instructions given below:
npm install <Node.js-Agent-unzipped-path>/agent_minified
npm install /users/joe/agent_minified
npm install -g <Node.js-Agent-unzipped-path>/agent_minified
npm install -g /users/joe/agent_minified
{
"licenseKey" : "[LICENSE-KEY]",
"appName" : "[APPLICATION-NAME]",
"port" : "[APPLICATION-PORT]",
"apmHost": "[APM-HOST-NAME]",
"apmPort": "[APM-SSL-PORT]"
}
Example:
{
"licenseKey" : "APMI_ee42094f83dd841d16b9c56796c22b63bef00ac6918f547280947d1f6c2be1ea",
"appName" : "APMInsight_NodeJSapp",
"port" : "3000",
"apmHost": "localhost",
"apmPort": "8443"
}
{
"licenseKey" : "[LICENSE-KEY]",
"appName" : "[APPLICATION-NAME]",
"port" : "[APPLICATION-PORT]",
"apmHost": "[APM-HOST-NAME]",
"apmPort": "[APM-SSL-PORT]"
"proxyServerHost" : "[PROXY-SERVER]",
"proxyServerPort" : "[PROXY-PORT]",
"proxyAuthUser" : "[PROXY-USERNAME]",
"proxyAuthPassword" : "[PROXY-PASSWORD]"
}
If using Common JS:
require('apminsight')()
If using ES:
import apminsight from 'apminsight';
apminsight.config()
require(‘apminsight’)
(
{port:<application port>}
)
However other parameters like license key and app name should be added only in apminsightnode.json file.
Note: We highly recommend downloading the latest version of the APM Insight Node.js agent. However, if you need to download agent versions below 1.7.2 for any specific reason, please refer to the steps provided below.
npm install <Node.js-Agent-unzipped-path>/agent_minified
npm install /users/joe/agent_minified
npm install -g <Node.js-Agent-unzipped-path>/agent_minified
npm install -g /users/joe/agent_minified
require('apminsight')({
licenseKey : '[LICENSE-KEY]',
appName : '[APPLICATION-NAME]',
port : [APPLICATION-PORT],
apmHost: '[APM-HOST-NAME]',
apmPort: [APM-SSL-PORT]
})
Example:
require('apminsight')({
licenseKey : 'APMI_ee42094f83dd841d16b9c56796c22b63bef00ac6918f547280947d1f6c2be1ea',
appName : 'Insight_NodeJS',
port : 3000,
apmHost: 'localhost',
apmPort: 8443
})
require('apminsight')({
licenseKey : '[LICENSE-KEY]',
appName : '[APPLICATION-NAME]',
port : [APPLICATION-PORT],
apmHost: '[APM-HOST-NAME]',
apmPort: [APM-SSL-PORT]
proxyServerHost : '[PROXY-SERVER]',
proxyServerPort : [PROXY-PORT],
proxyAuthUser : '[PROXY-USERNAME]',
proxyAuthPassword : '[PROXY-PASSWORD]'
})