Configurationedit
While initializing the agent you can provide the following configuration options:
serviceName
edit
- Type: String
- Required
Your Elastic APM service name.
serverUrl
edit
- Type: String
-
Default:
http://localhost:8200
The URL used to make requests to the APM Server.
serviceVersion
edit
- 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.
active
edit
- 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 }
instrument
edit
- 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.
disableInstrumentations
edit
- Type: Array
-
Default:
[]
A list of instrumentations which can be disabled. When disabled, no transactions/spans will be created for that type. Valid options:
-
page-load
-
history
-
eventtarget
-
xmlhttprequest
-
fetch
-
error
To disable all http-request
transactions, you should add both fetch
and xmlhttprequest
.
to this config.
To disable user-interaction
transactions, you should add eventtarget
to this config.
environment
edit
- 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 app. It’s important to be consistent when naming environments across agents. See environment selector in the APM app for more information.
This feature is fully supported in the APM app in Kibana versions >= 7.2. You must use the query bar to filter for a specific environment in versions prior to 7.2.
logLevel
edit
- 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
.
apiVersion
edit
- Type: number
-
Default:
2
Denotes the version of APM Server’s intake API. Setting this value to any number
above 2
will compress the events(transactions & errors) payload sent to the server.
This feature requires APM Server >= 7.8. Setting this flag to number > 2 with older APM server version would break the RUM payload from reaching the server.
breakdownMetrics
edit
- Type: Boolean
-
Default:
false
Enable/disable the tracking and collection of breakdown metrics for the transaction.
This feature requires APM Server and Kibana >= 7.4. Setting this flag to true
with older APM server version
would break the RUM payload from reaching the server.
Breakdown distribution for the transaction varies depending on the type of the transaction. To understand the different types, see Breakdown Metrics
flushInterval
edit
- Type: Number
-
Default:
500
The agent maintains a single queue to record transaction and error events when they are added. This option sets the flush interval in milliseconds for the queue.
After each flush of the queue, the next flush isn’t scheduled until an item is added to the queue.
pageLoadTraceId
edit
- Type: String
Use this option to override the page load transaction’s trace ID.
pageLoadSampled
edit
- Type: String
Use this option to override the page load transaction’s sampled property.
pageLoadSpanId
edit
- Type: String
This option overrides the ID of the span that is generated for receiving the initial document.
pageLoadTransactionName
edit
- Type: String
This option sets the name for the page load transaction. By default, transaction names for hard (page load) and soft (route change) navigations are inferred by the agent based on the current URL. Check the custom initial page load transaction names documentation for more details.
distributedTracing
edit
- Type: Boolean
-
Default:
true
Distributed tracing is enabled by default, however you can use this configuration to disable it.
distributedTracingOrigins
edit
- Type: Array
-
Default:
[]
This option can be set to an array containing one or more Strings or RegExp objects and determines which origins should be monitored as part of distributed tracing.
More specifically, this option is consulted when the agent is about to add the distributed tracing HTTP header (traceparent
) to a request.
Please note that each item in the array should be a valid URL containing the origin (other parts of the url are ignored) or a RegExp object. If an item in the array is a String, an exact match will be performed. If it’s a RegExp object, its test function will be called with the request origin.
var options = { distributedTracingOrigins: ['https://example.com', /https?:\/\/example\.com:\d{4}/] }
propagateTracestate
edit
- Type: Boolean
-
Default:
false
When distributed tracing is enabled, this option can be used to propagate the tracestate HTTP header to the configured origins. Before enabling this flag, make sure to change your server configuration to avoid Cross-Origin Resource Sharing errors.
Event throttlingedit
Throttle the number of events sent to APM Server.
eventsLimit
edit
By default, the agent can only send up to 80
events every 60000
milliseconds (one minute).
- Type: Number
-
Default:
80
transactionSampleRate
edit
- 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.
centralConfig
edit
- Type: Boolean
-
Default:
false
This option activates APM Agent Configuration via Kibana.
When set to true
, the agent starts fetching configurations via the APM Server during the initialization phase.
These central configurations are cached in sessionStorage
, and will not be fetched again until
the session is closed and/or sessionStorage
is cleared.
In most cases, this means when the tab/window of the page is closed.
Currently, only transaction sample rate can be configured via Kibana.
This feature requires APM Server v7.5 or later and that the APM Server is configured with kibana.enabled: true
.
More information is available in APM Agent configuration.
ignoreTransactions
edit
- Type: Array
-
Default:
[]
Array containing a list of transactions names that should be ignored when sending the payload to the APM server. It can be set to an array containing one or more Strings or RegExp objects. If an element in the array is a String, an exact match will be performed. If an element in the array is a RegExp object, its test function will be called with the name of the transation.
const options = { ignoreTransactions: [/login*/, '/app'] }
Spans that are captured as part of the ignored transactions would also be ignored.
monitorLongtasks
edit
- Type: Boolean
-
Default:
true
Instructs the agent to start monitoring for browser tasks that block the UI thread and might delay other user inputs by affecting the overall page responsiveness. Learn more about long task spans and how to interpret them.