Configuration
editConfiguration
editTo adapt the Elastic APM agent to your needs, you can configure it using environment variables, or framework specific configuration.
Django
editTo configure Django, add an ELASTIC_APM
dictionary to your settings.py
:
ELASTIC_APM = { 'APP_NAME': 'my-app', 'SECRET_TOKEN': 'changeme', }
Flask
editTo configure Flask, add an ELASTIC_APM
dictonary to your app.config
:
app.config['ELASTIC_APM'] = { 'APP_NAME': 'my-app', 'SECRET_TOKEN': 'changeme', } apm = ElasticAPM(app)
Required options
editapp_name
editEnvironment | Django/Flask | Default | Example |
---|---|---|---|
|
|
|
|
The name of your app. This is used to keep all the errors and transactions of your app together and is the primary filter in the Elastic APM user interface.
The app name must conform to this regular expression: ^[a-zA-Z0-9 _-]+$
.
In less regexy terms:
Your app name must only contain characters from the ASCII alphabet, numbers, dashes, underscores and spaces.
server_url
editEnvironment | Django/Flask | Default |
---|---|---|
|
|
|
The URL for your APM Server.
The URL must be fully qualified, including protocol (http
or https
) and port.
transport_class
editEnvironment |
Django/Flask |
Default |
|
|
|
The transport class to use when sending events to the APM server.
The default AsyncTransport
uses a background thread to send data.
If your environment doesn’t allow background threads, you can use
elasticapm.transport.http.Transport
instead.
Note however that this can have adverse effects on performance.
Other options
editsecret_token
editEnvironment | Django/Flask | Default | Example |
---|---|---|---|
|
|
|
A random string |
This string is used to ensure that only your agents can send data to your APM server. Both the agents and the APM server have to be configured with the same secret token. One example to generate a secure secret token is:
python -c "import uuid; print(str(uuid.uuid4()))"
secret tokens only provide any security if your APM server use TLS.
app_version
editEnvironment | Django/Flask | Default | Example |
---|---|---|---|
|
|
|
A string indicating the version of the deployed app |
A version string for the currently deployed version of the app.
If you don’t version your deployments,
the recommended value for this field is the commit identifier of the deployed revision, e.g. the output of git rev-parse HEAD
.
framework_name
editEnvironment | Django/Flask | Default |
---|---|---|
|
|
Depending on framework |
Name of the used framework.
For Django and Flask, this defaults to django
and flask
respectively,
otherwise, the default is None
.
framework_version
editEnvironment | Django/Flask | Default |
---|---|---|
|
|
Depending on framework |
Version number of the used framework.
For Django and Flask, this defaults to the used version of the framework,
otherwise, the default is None
.
filter_exception_types
editEnvironment | Django/Flask | Default | Example |
---|---|---|---|
|
|
|
|
multiple values separated by commas, without spaces |
A list of exception types to be filtered. Exceptions of these types will not be sent to the APM server.
transactions_ignore_patterns
editEnvironment | Django/Flask | Default | Example |
---|---|---|---|
|
|
|
|
multiple values separated by commas, without spaces |
A list of regular expressions. Transactions that match any of the of the configured patterns will be ignored and not sent to the APM server.
timeout
editEnvironment | Django/Flask | Default |
---|---|---|
|
|
|
A timeout in seconds.
If a request to the APM server takes longer than the configured timeout,
the request is cancelled and the event (exception or transaction) is discarded.
Set to None
to disable timeouts.
If timeouts are disabled or set to a high value, your app could experience memory issues if the APM server times out.
hostname
editEnvironment | Django/Flask | Default | Example |
---|---|---|---|
|
|
|
|
The host name to use when sending error and transaction data to the APM server.
auto_log_stacks
editEnvironment | Django/Flask | Default |
---|---|---|
|
|
|
set to |
If set to True
(the default), the agent will add a stack trace to each log event,
indicating where the log message has been issued.
This setting can be overridden on an individual basis by setting the extra
-key stack
:
logger.info('something happened', extra={'stack': False})
traces_send_frequency
editEnvironment |
Django/Flask |
Default |
|
|
|
Interval with which transactions should be sent to the APM server, in seconds. A lower value will increase the load on your APM server, while a higher value can increase the memory pressure of your app. A higher value also impacts the time until transactions are indexed and searchable in Elasticsearch.
max_event_queue_length
editEnvironment |
Django/Flask |
Default |
|
|
|
Maximum queue length of transactions before sending transactions to the APM server. A lower value will increase the load on your APM server, while a higher value can increase the memory pressure of your app. A higher value also impacts the time until transactions are indexed and searchable in Elasticsearch.
This setting is useful to limit memory consumption if you experience a sudden spike of traffic.
processors
editEnvironment |
Django/Flask |
Default |
|
|
|
A list of processors to process transactions and errors. For more information, see Sanitizing Data.
We recommend to always include the default set of validators if you customize this setting.
include_paths
editEnvironment |
Django/Flask |
Default |
|
|
Depending on framework |
multiple values separated by commas, without spaces |
A set of module paths that should be considered when detecting if a stacktrace frame is a library frame or an "in-app" frame.
For Django, the default set is the list of INSTALLED_APPS
, but without django.contrib
apps.
For Flask, it’s the app module.
for a given module path, all sub-modules will also match. E.g. foo.bar
also matches for foo.bar.baz
.
exclude_paths
editEnvironment |
Django/Flask |
Default |
|
|
Depending on framework |
multiple values separated by commas, without spaces |
A set of module paths that should be considered when excluding a frame from being detected as an in-app frame.
exclude_paths
takes precedence over include_paths
.
For Django, the default is set to {'elasticapm', 'django'}
.
Everywhere else, the default is set(['elasticapm'])
.
for a given module path, all sub-modules will also match. E.g. foo.bar
also matches for foo.bar.baz
.
debug
editEnvironment |
Django/Flask |
Default |
|
|
|
If your app is in debug mode (e.g. in Django with settings.DEBUG = True
or in Flask with app.debug = True
),
the agent won’t send any data to the APM server. You can override it by changing this setting to True
.
disable_send
editEnvironment |
Django/Flask |
Default |
|
|
|
If set to True
, the agent won’t send any events to the APM server, independent of any debug state.
disable_instrumentation
editEnvironment |
Django/Flask |
Default |
|
|
|
If set to True
, the agent won’t instrument any code.
This disables most of the tracing functionality, but can be useful to debug possible instrumentation issues.
verify_server_cert
editEnvironment |
Django/Flask |
Default |
|
|
|
By default, the agent verifies the SSL certificate if you use an HTTPS connection to the APM server.
Verification can be disabled by changing this setting to False
.
SSL certificate verification is only available in Python 2.7.9+ and Python 3.4.3+.