Setting Up APM (Application Performance Monitoring) for 1C-Bitrix
APM is continuous monitoring of application performance in real time: response time, error count, slow queries, performance degradation under load. Unlike profilers (Xdebug, Blackfire), which run manually, APM works continuously and alerts before clients start complaining.
What APM for Bitrix Consists Of
For 1C-Bitrix, two stacks are commonly used in practice: Elastic APM (open-source, self-hosted) and New Relic / Datadog (SaaS). The principle is the same — a PHP agent intercepts request execution and sends metrics to a central storage.
Elastic APM — architecture:
PHP-agent (elastic-apm-php) → APM Server → Elasticsearch → Kibana (APM UI)
PHP Agent Installation:
# Debian/Ubuntu
curl -L -O https://github.com/elastic/apm-agent-php/releases/download/v1.x.x/apm-agent-php_Linux_x86-64.deb
dpkg -i apm-agent-php_Linux_x86-64.deb
In php.ini:
extension=elastic_apm.so
elastic_apm.server_url=http://apm-server:8200
elastic_apm.service_name=bitrix-site
elastic_apm.environment=production
elastic_apm.transaction_sample_rate=0.1
transaction_sample_rate=0.1 — profiles 10% of requests. On heavily loaded sites, 100% causes noticeable overhead.
What APM Monitors in Bitrix
The agent automatically intercepts:
- Incoming HTTP requests — response time, status, URL, method.
-
SQL queries — to
b_iblock_element,b_sale_order,b_crm_dealand all other tables. Visible: query time, body, execution plan. -
External HTTP calls —
curl_exec,file_get_contents. Requests to 1C, payment systems, external APIs. -
Exceptions —
\Bitrix\Main\SystemException, unhandled errors.
For custom operations (long import script, heavy aggregation), create a span manually:
use Elastic\Apm\ElasticApm;
$transaction = ElasticApm::getCurrentTransaction();
$span = $transaction->beginCurrentContextSpan('import.products', 'custom');
// ... import logic ...
$span->end();
Key Metrics and Alerts
After setup, Kibana APM UI provides:
- Response time — average and 95th percentile response time by URL.
- Throughput — requests per minute.
- Error rate — percentage of requests with errors.
- Apdex — satisfaction index: ratio of fast (< T), tolerable (< 4T), and slow requests.
Alerts are configured in Kibana Alerting: if p95 response time exceeds 3 seconds for more than 5 minutes — notification to Slack or email.
Setup Timeline
| Stage | Duration |
|---|---|
| APM Server + Elasticsearch installation | 1 day |
| PHP agent setup, first data | 2–4 hours |
| Dashboard and alert configuration | 1 day |
| Fine-tuning (sampling, custom spans) | 1–2 days |
APM does not replace profiling — it shows what degrades and when. A profiler explains why.







