Configurationedit

You can utilize configuration options to adapt the Elastic APM agent to your needs. One way to do this is to configure settings via the php.ini file:

elastic_apm.server_url=http://localhost:8200
elastic_apm.service_name="My service"

The agent can also be configured using environment variables:

export ELASTIC_APM_SERVER_URL="http://localhost:8200"
export ELASTIC_APM_SERVICE_NAME="My service"

If you use environment variables to configure the agent, make sure the process running your PHP code inherits those environment variables after they were set.

Elasticsearch Service on Elastic Cloudedit

The agent can be configured to send data to an Elasticsearch Service APM instance by setting server_url and secret_token options to the corresponding values found in the APM section of Elastic Cloud:

Example view of Elastic Cloud host and secret_token

Configure the agent, for example via php.ini:

elastic_apm.server_url=APM_SERVER_URL
elastic_apm.secret_token=TOKEN
elastic_apm.service_name=SERVICE_NAME

Loggingedit

The easiest way to configure the logging is by using the log_level_syslog configuration option.

Available log levels are:

OFF
CRITICAL
ERROR
WARNING
NOTICE
INFO
DEBUG
TRACE

For example, if you specify WARNING log level, only log records with levels WARNING, ERROR and CRITICAL will be emitted.

OFF is only used to disable agent logging. There cannot be log records with level OFF.

The agent supports logging to the following sinks: syslog and stderr. You can control the level of logging for individual sinks with the log_level_syslog and log_level_stderr options. When a sink-specific logging level is not set explicitly, the fallback setting, log_level, will be used.

For example, the following configuration sets the log level to NOTICE for all the sinks:

elastic_apm.log_level=NOTICE

Alternatively, the following configuration sets log level to NOTICE for all the sinks except for syslog, which log level is set to TRACE.

elastic_apm.log_level=NOTICE
elastic_apm.log_level_syslog=TRACE