Elastic APM Stack
Elasticsearch APM with Kibana for application monitoring.
Overview
Elasticsearch is a distributed search and analytics engine built on Apache Lucene that has become the cornerstone of modern observability platforms. Originally developed by Elastic N.V., it provides real-time indexing and search capabilities across massive datasets, making it ideal for log analytics, application performance monitoring, and business intelligence. Its distributed architecture with automatic sharding and replication ensures high availability and horizontal scalability. This Elastic APM Stack combines Elasticsearch with Kibana (the visualization and management interface) and APM Server (the data collection component) to create a comprehensive application performance monitoring solution. APM Server receives performance data from instrumented applications via lightweight agents, processes and enriches this data, then stores it in Elasticsearch indices optimized for time-series analysis. Kibana provides pre-built dashboards and visualizations specifically designed for APM data, including service maps, transaction traces, and error analytics. Development teams and DevOps engineers seeking deep visibility into application performance, error tracking, and dependency mapping will find this stack invaluable. Unlike basic logging solutions, this combination provides distributed tracing capabilities that track requests across microservices, automatic service discovery and mapping, and machine learning-powered anomaly detection for proactive issue identification.
Key Features
- Distributed tracing across microservices with automatic span correlation and timing analysis
- Real-time application metrics collection including response times, throughput, and error rates
- Service topology mapping that automatically discovers and visualizes application dependencies
- Machine learning anomaly detection for proactive identification of performance degradations
- Custom dashboards and alerting through Kibana's visualization engine
- Support for multiple programming languages through official APM agents
- Index lifecycle management for automatic data retention and cost optimization
- Cross-cluster search capabilities for monitoring distributed application environments
Common Use Cases
- 1Microservices performance monitoring in production environments with distributed request tracing
- 2E-commerce platform optimization by identifying slow database queries and API bottlenecks
- 3SaaS application error tracking and root cause analysis across multiple service tiers
- 4DevOps teams implementing observability-driven development practices with CI/CD integration
- 5Enterprise applications requiring compliance auditing and performance SLA monitoring
- 6Startup development teams establishing performance baselines during rapid scaling phases
- 7Legacy application modernization projects needing visibility during cloud migration
Prerequisites
- Minimum 4GB RAM available for Elasticsearch heap allocation and optimal query performance
- Docker and Docker Compose installed with at least 20GB available disk space for indices
- Network ports 9200, 5601, and 8200 available and not conflicting with existing services
- Basic understanding of APM concepts including transactions, spans, and distributed tracing
- Application instrumentation knowledge for integrating APM agents into your codebase
- JVM tuning experience recommended for production Elasticsearch deployments
For development & testing. Review security settings, change default credentials, and test thoroughly before production use. See Terms
docker-compose.yml
docker-compose.yml
1services: 2 elasticsearch: 3 image: docker.elastic.co/elasticsearch/elasticsearch:8.11.04 container_name: elastic-apm-es5 restart: unless-stopped6 environment: 7 - discovery.type=single-node8 - xpack.security.enabled=false9 - "ES_JAVA_OPTS=-Xms512m -Xmx512m"10 volumes: 11 - es_data:/usr/share/elasticsearch/data12 ports: 13 - "${ES_PORT:-9200}:9200"1415 kibana: 16 image: docker.elastic.co/kibana/kibana:8.11.017 container_name: elastic-apm-kibana18 restart: unless-stopped19 ports: 20 - "${KIBANA_PORT:-5601}:5601"21 environment: 22 - ELASTICSEARCH_HOSTS=http://elasticsearch:920023 depends_on: 24 - elasticsearch2526 apm-server: 27 image: docker.elastic.co/apm/apm-server:8.11.028 container_name: apm-server29 restart: unless-stopped30 ports: 31 - "${APM_PORT:-8200}:8200"32 environment: 33 - output.elasticsearch.hosts=["elasticsearch:9200"]34 depends_on: 35 - elasticsearch3637volumes: 38 es_data: .env Template
.env
1# Elastic APM2ES_PORT=92003KIBANA_PORT=56014APM_PORT=8200Usage Notes
- 1Kibana at http://localhost:5601
- 2APM Server at http://localhost:8200
- 3Configure APM agents with server URL
- 4View APM in Kibana Observability
Individual Services(3 services)
Copy individual services to mix and match with your existing compose files.
elasticsearch
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:8.11.0
container_name: elastic-apm-es
restart: unless-stopped
environment:
- discovery.type=single-node
- xpack.security.enabled=false
- ES_JAVA_OPTS=-Xms512m -Xmx512m
volumes:
- es_data:/usr/share/elasticsearch/data
ports:
- ${ES_PORT:-9200}:9200
kibana
kibana:
image: docker.elastic.co/kibana/kibana:8.11.0
container_name: elastic-apm-kibana
restart: unless-stopped
ports:
- ${KIBANA_PORT:-5601}:5601
environment:
- ELASTICSEARCH_HOSTS=http://elasticsearch:9200
depends_on:
- elasticsearch
apm-server
apm-server:
image: docker.elastic.co/apm/apm-server:8.11.0
container_name: apm-server
restart: unless-stopped
ports:
- ${APM_PORT:-8200}:8200
environment:
- output.elasticsearch.hosts=["elasticsearch:9200"]
depends_on:
- elasticsearch
Quick Start
terminal
1# 1. Create the compose file2cat > docker-compose.yml << 'EOF'3services:4 elasticsearch:5 image: docker.elastic.co/elasticsearch/elasticsearch:8.11.06 container_name: elastic-apm-es7 restart: unless-stopped8 environment:9 - discovery.type=single-node10 - xpack.security.enabled=false11 - "ES_JAVA_OPTS=-Xms512m -Xmx512m"12 volumes:13 - es_data:/usr/share/elasticsearch/data14 ports:15 - "${ES_PORT:-9200}:9200"1617 kibana:18 image: docker.elastic.co/kibana/kibana:8.11.019 container_name: elastic-apm-kibana20 restart: unless-stopped21 ports:22 - "${KIBANA_PORT:-5601}:5601"23 environment:24 - ELASTICSEARCH_HOSTS=http://elasticsearch:920025 depends_on:26 - elasticsearch2728 apm-server:29 image: docker.elastic.co/apm/apm-server:8.11.030 container_name: apm-server31 restart: unless-stopped32 ports:33 - "${APM_PORT:-8200}:8200"34 environment:35 - output.elasticsearch.hosts=["elasticsearch:9200"]36 depends_on:37 - elasticsearch3839volumes:40 es_data:41EOF4243# 2. Create the .env file44cat > .env << 'EOF'45# Elastic APM46ES_PORT=920047KIBANA_PORT=560148APM_PORT=820049EOF5051# 3. Start the services52docker compose up -d5354# 4. View logs55docker compose logs -fOne-Liner
Run this command to download and set up the recipe in one step:
terminal
1curl -fsSL https://docker.recipes/api/recipes/elastic-apm-stack/run | bashTroubleshooting
- Elasticsearch container fails to start with 'max virtual memory areas vm.max_map_count too low': Increase vm.max_map_count to 262144 using sysctl -w vm.max_map_count=262144
- APM agents cannot connect showing 'connection refused' errors: Verify APM server is accessible at port 8200 and check firewall rules between application and container network
- Kibana displays 'Elasticsearch cluster did not respond' warnings: Wait 30-60 seconds for Elasticsearch to complete startup and index creation before accessing Kibana
- High memory usage causing container restarts: Adjust ES_JAVA_OPTS heap settings based on available system memory, recommended minimum -Xms1g -Xmx1g for production
- APM data not appearing in Kibana despite successful agent connections: Check APM server logs for parsing errors and verify agent compatibility with server version
- Disk space filling rapidly with APM indices: Configure index lifecycle policies in Kibana to automatically delete old data after specified retention periods
Community Notes
Loading...
Loading notes...
Download Recipe Kit
Get all files in a ready-to-deploy package
Includes docker-compose.yml, .env template, README, and license
Components
elasticsearchkibanaapm-server
Tags
#elastic#apm#observability#kibana
Category
Monitoring & ObservabilityAd Space
Shortcuts: C CopyF FavoriteD Download