Configurationedit

While initializing the agent you can provide the following configuration options:

serviceNameedit

  • Type: String
  • Required

Your Elastic APM service name.

serverUrledit

  • Type: String
  • Default: http://localhost:8200

The URL used to make requests to the APM Server.

serviceVersionedit

  • Type: String

The version of the app. This could be the version from your package.json file, a git commit reference, or any other string that might help you pinpoint a specific version. Furthermore this option is used on the APM Server to find the right sourcemap file to apply to the stack trace.

activeedit

  • Type: Boolean
  • Default: true

A boolean specifying if the agent should be active or not. If active, the agent will send APM transactions and track errors. This option can be used to deactivate the agent in your staging environment. It can also be used to sample a number of clients, here is an example to sample 10% of the page loads:

var options = {
  active: Math.random() < 0.1
}

instrumentedit

  • Type: Boolean
  • Default: true

A boolean specifying if the agent should automatically instrument the application to collect performance metrics for the application.

Both active and instrument needs to be true for instrumentation to be running.

disableInstrumentationsedit

  • Type: Array
  • Default: []

A list of instrumentations which can be disabled. Valid options are xmlhttprequest, fetch, history, error and page-load. When disabled, no transactions/spans will be created for that type.

environmentedit

  • Type: String
  • Default: ``

Environment where the service being monitored is deployed, e.g. "production", "development", "test", etc.

Environments allow you to easily filter data on a global level in the APM UI. It’s important to be consistent when naming environments across agents. See environment selector in the Kibana UI for more information.

This feature is fully supported in the APM UI in Kibana versions >= 7.2. You must use the query bar to filter for a specific environment in versions prior to 7.2.

logLeveledit

  • Type: String
  • Default: 'warn'

Set the verbosity level for the agent. Note that this does not have any influence on the types of errors that are sent to the APM Server. This option is useful when you want to report an issue with the agent to us.

Possible levels are: trace, debug, info, warn, error.

flushIntervaledit

  • Type: Number
  • Default: 500

The agent maintains two in-memory queues to record transactions and errors when they are added. This option sets the flush interval in milliseconds for these queues.

After each flush of the queue, the next flush isn’t scheduled until an item is added to the queue.

pageLoadTraceIdedit

  • Type: String

Use this option to override the page load transaction’s trace ID.

pageLoadSamplededit

  • Type: String

Use this option to override the page load transaction’s sampled property.

pageLoadSpanIdedit

  • Type: String

This option overrides the ID of the span that is generated for receiving the initial document.

pageLoadTransactionNameedit

  • Type: String

This option sets the name for the page load transaction. See the custom initial page load transaction names documentation for strategies on using this method.

distributedTracingedit

  • Type: Boolean
  • Default: true

Distributed tracing is enabled by default, however you can use this configuration to disable it.

distributedTracingOriginsedit

  • Type: Array
  • Default: []

This option is an array of strings and determines which origins should be monitored as part of distributed tracing. More specificly this option is consulted when the agent is about to add distributed tracing http header (elastic-apm-traceparent) to a request. Please note that each item in the array should be a valid url and at least include the origin part (other parts of the url are ignored).

var options = {
  distributedTracingOrigins: ['https://example.com']
}

Error throttlingedit

To throttle the number of errors send to the APM Server, you can use the following options:

errorThrottleLimitedit

  • Type: Number
  • Default: 20

errorThrottleIntervaledit

  • Type: Number
  • Default: 30000

By default the agent can only send (up to) 20 errors every 30000 milliseconds.

Transaction throttlingedit

transactionThrottleLimitedit

  • Type: Number
  • Default: 20

transactionThrottleIntervaledit

  • Type: Number
  • Default: 30000

By default the agent can only send (up to) 20 transactions every 30000 milliseconds.

transactionSampleRateedit

  • Type: Number
  • Default: 1.0

A number between 0.0 and 1.0 that specifies the sample rate of transactions, by default all transactions are sampled.