Configurationedit

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

elastic_apm.server_url = http://localhost:8200
elastic_apm.service_name = "Unknown PHP service"
elastic_apm.log_level = 0

The agent can also be configured at runtime with the following PHP code:

ini_set('elastic_apm.server_url', 'http://localhost:8200');
ini_set('elastic_apm.service_name', 'My_Test_Service');
ini_set('elastic_apm.log_level', 'DEBUG');

Elasticsearch Service on Elastic Cloudedit

The agent can be configured to send data to an Elasticsearch Service APM instance by configuring the elastic_apm.server_url and elastic_apm.secret_token found in the APM section of Elastic Cloud:

Example view of Elastic Cloud host and secret_token

Configure in elastic_apm.ini:

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

Or, with the following PHP code:

ini_set('elastic_apm.server_url', 'APM_SERVER_URL');
ini_set('elastic_apm.secret_token', 'TOKEN');

Loggingedit

Available log levels are:

OFF
CRITICAL
ERROR
WARNING
NOTICE
INFO
DEBUG
TRACE

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

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

The agent supports logging to the following sinks: syslog and stderr. You can control the level of logging for individual sinks with the elastic_apm.log_level_syslog and elastic_apm.log_level_stderr keys. When a sink-specific logging level is not set explicitly, the fallback setting, elastic_apm.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, whose log level is set to TRACE.

elastic_apm.log_level=NOTICE
elastic_apm.log_level_syslog=TRACE