IMPORTANT: No additional bug fixes or documentation updates
will be released for this version. For the latest information, see the
current release documentation.
Configuring the agent
editConfiguring the agent
editThere are three ways to configure the Node.js agent. In order of precedence (higher overwrites lower):
-
APM Agent Configuration via Kibana. Enabled with
centralConfig
. - Environment variables.
-
If calling the
apm.start()
function, you can supply a configurations object as the first argument. - Via the agent configuration file.
For information on the available configuration properties, and the expected names of environment variables, see the Configuration options documentation.
Agent configuration object
editTo use the optional options
argument, simply pass it into the apm.start()
method:
var apm = require('elastic-apm-node').start({ // add configuration options here })
Here’s an example usage configuring the agent to only be active in production:
// Add this to the VERY top of the first file loaded in your app require('elastic-apm-node').start({ // Override service name from package.json // Allowed characters: a-z, A-Z, 0-9, -, _, and space serviceName: '', // Use if APM Server requires a token secretToken: '', // Set custom APM Server URL (default: http://localhost:8200) serverUrl: '', // Only activate the agent if it's running in production active: process.env.NODE_ENV === 'production' })
Agent configuration file
editThe Node.js agent will look for a file named elastic-apm-node.js
in the current working directory.
You can specify a custom path for this file using the configFile
config option.