Configuration

edit

To adapt the Elastic APM Go agent to your needs, you can configure it using environment variables.

By default, the agent will attempt to send data to the Elastic APM Server at http://localhost:8200, to simplify development and testing. To send data to an alternative location, you must configure ELASTIC_APM_SERVER_URL. Depending on the configuration of your server, you may also need to set ELASTIC_APM_SECRET_TOKEN and ELASTIC_APM_VERIFY_SERVER_CERT. All other variables have usable defaults.

ELASTIC_APM_SERVER_URL

edit
Environment Default Example

ELASTIC_APM_SERVER_URL

http://localhost:8200

http://localhost:8200

The URL for your Elastic APM server. The server supports both HTTP and HTTPS. If you use HTTPS, then you may need to configure your client machines so that the server certificate can be verified. You can also disable certificate verification with ELASTIC_APM_VERIFY_SERVER_CERT.

ELASTIC_APM_SERVER_TIMEOUT

edit
Environment Default Example

ELASTIC_APM_SERVER_TIMEOUT

30s

30s

The timeout for requests made to your Elastic APM server. When set to zero or a negative value, timeouts will be disabled.

ELASTIC_APM_SECRET_TOKEN

edit
Environment Default Example

ELASTIC_APM_SECRET_TOKEN

"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.

the secret token is sent as plain-text in every request to the server, so you should also secure your communications using HTTPS. Unless you do so, your secret token could be observed by an attacker.

ELASTIC_APM_SERVICE_NAME

edit
Environment Default Example

ELASTIC_APM_SERVICE_NAME

Executable name

my-app

The name of your service/application. This is used to keep all the errors and transactions of your service together and is the primary filter in the Elastic APM user interface.

If you do not specify ELASTIC_APM_SERVICE_NAME, the Go agent will use the executable name. e.g. if your executable is called "my-app.exe", then your service will be identified as "my-app".

The service name must conform to this regular expression: ^[a-zA-Z0-9 _-]+$. In other words: your service name must only contain characters from the ASCII alphabet, numbers, dashes, underscores and spaces.

ELASTIC_APM_SERVICE_VERSION

edit
Environment Default Example

ELASTIC_APM_SERVICE_VERSION

A string indicating the version of the deployed service

A version string for the currently deployed version of the service. 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.

ELASTIC_APM_ENVIRONMENT

edit
Environment Default Example

ELASTIC_APM_ENVIRONMENT

"production"

The name of the environment this service is deployed in, e.g. "production" or "staging".

the APM UI does not currently group services by environment, so metrics for all environments will be combined. Consider changing the service name if you want to see the metrics separated by environment. Alternatively, you can use the search bar introduced with the 6.4 release.

ELASTIC_APM_ACTIVE

edit
Environment Default Example

ELASTIC_APM_ACTIVE

true

false

Enable or disable the tracer. If set to false, then the Go agent does not send any data to the Elastic APM server, and instrumentation overhead is minimized.

ELASTIC_APM_IGNORE_URLS

edit
Environment Default Example

ELASTIC_APM_IGNORE_URLS

/heartbeat|/_internal/.*

A regular expression matching the request line of HTTP requests for which transactions should not be reported.

The pattern specified in ELASTIC_APM_IGNORE_URLS is treated case-insensitively by default. To override this behavior and match case-sensitively, wrap the value like (?-i:<value>). For a full definition of Go’s regular expression syntax, see https://golang.org/pkg/regexp/syntax/.

ELASTIC_APM_SANITIZE_FIELD_NAMES

edit
Environment Default Example

ELASTIC_APM_SANITIZE_FIELD_NAMES

password|passwd|pwd|secret|.*key|.*token|.*session.*|.*credit.*|.*card.*

sekrits

A regular expression matching the names of HTTP cookies and POST form fields to redact.

The pattern specified in ELASTIC_APM_SANITIZE_FIELD_NAMES is treated case-insensitively by default. To override this behavior and match case-sensitively, wrap the value like (?-i:<value>). For a full definition of Go’s regular expression syntax, see https://golang.org/pkg/regexp/syntax/.

ELASTIC_APM_CAPTURE_BODY

edit
Environment Default

ELASTIC_APM_CAPTURE_BODY

off

For transactions that are HTTP requests, the Go agent can optionally capture the request body.

Possible values: errors, transactions, all, off.

request bodies often contain sensitive values like passwords, credit card numbers, etc. If your service handles data like this, enable this feature with care.

ELASTIC_APM_HOSTNAME

edit
Environment Default Example

ELASTIC_APM_HOSTNAME

os.Hostname()

app-server01

The host name to use when sending error and transaction data to the APM server.

ELASTIC_APM_FLUSH_INTERVAL

edit
Environment Default

ELASTIC_APM_FLUSH_INTERVAL

10s

Amount of time to wait before sending transactions to the Elastic APM server. Transactions will be batched up and sent periodically. Errors are always sent as soon as possible.

A lower value will increase the load on your APM server, while a higher value can increase the memory pressure on your app. A higher value also impacts the time until transactions are indexed and searchable in Elasticsearch.

ELASTIC_APM_TRANSACTION_MAX_SPANS

edit
Environment Default

ELASTIC_APM_TRANSACTION_MAX_SPANS

500

Limits the amount of spans that are recorded per transaction.

This is helpful in cases where a transaction creates a large number of spans (e.g. thousands of SQL queries). Setting an upper limit will prevent overloading the agent and the APM server with too much work for such edge cases.

ELASTIC_APM_SPAN_FRAMES_MIN_DURATION

edit
Environment Default

ELASTIC_APM_SPAN_FRAMES_MIN_DURATION

5ms

The APM agent will collect a stack trace for every recorded span whose duration exceeds this configured value. While this is very helpful to find the exact place in your code that causes the span, collecting this stack trace does have some processing and storage overhead.

ELASTIC_APM_MAX_QUEUE_SIZE

edit
Environment Default

ELASTIC_APM_MAX_QUEUE_SIZE

500

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. The queue will not grow beyond the configured size; once it has reached capacity, old transactions are dropped in favour of new ones.

ELASTIC_APM_TRANSACTION_SAMPLE_RATE

edit
Environment Default

ELASTIC_APM_TRANSACTION_SAMPLE_RATE

1.0

By default, the agent will sample every transaction (e.g. request to your service). To reduce overhead and storage requirements, you can set the sample rate to a value between 0.0 and 1.0. We still record overall time and the result for unsampled transactions, but no context information, tags, or spans.

ELASTIC_APM_VERIFY_SERVER_CERT

edit
Environment Default

ELASTIC_APM_VERIFY_SERVER_CERT

true

By default, the agent verifies the server’s certificate if you use an HTTPS connection to the APM server. Verification can be disabled by changing this setting to false.

ELASTIC_APM_DEBUG

edit
Environment Default

ELASTIC_APM_DEBUG

ELASTIC_APM_DEBUG can be used to debug issues with the Elastic APM Go agent or your instrumentation. The value should be a comma-separated list of key=value debug directives. Currently we support just one: tracetransport=1.

By setting ELASTIC_APM_DEBUG="tracetransport=1", the Go agent will log all transport calls to the terminal.