Application Performance Monitoring with Elastic APM Tool

Mithun Khatri

Mithun Khatri

Software Engineer

link

Introduction

Elastic APM is a powerful tool which can be used to monitor overall application health and performance. It enables us to drill down to each and every dependent internal api calls, databases calls etc. and reveals hidden secrets.


Getting Started

Required tools

  1. Docker
  2. elastic-apm-agent Java agent can be downloaded from : https://search.maven.org/search?q=a:elastic-apm-agent

Below steps can be followed to integrate application with APM tool and configure to start profiling.

docker-compose up -d below docker compose file

version: '3'
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:6.6.1
ports:
- "9200:9200"
kibana:
image: docker.elastic.co/kibana/kibana:6.6.1
ports:
- "5601:5601"
depends_on:
- elasticsearch
apm-server:
image: docker.elastic.co/apm/apm-server:6.6.1
environment:
- output.elasticsearch.hosts=["elasticsearch:9200"]
ports:
- "8200:8200"
depends_on:
- elasticsearch

At this point, ElasticSearch, Kibana and apm-server have been wired together and ready to be attached to your application.

Now, start the application with the javaagent and pointing to apm-server url

java -javaagent:/<path-to-jar>/elastic-apm-agent-<version>.jar \
-Delastic.apm.service_name=my-application \
-Delastic.apm.server_url=http://localhost:8200 \
-Delastic.apm.secret_token= \
-Delastic.apm.application_packages=<base package> \
-jar <jar name>.jar

Here,

apm.service_name โ†’ It can be the service name apm.server_url โ†’ url to apm server apm.application_packages โ†’ package where main class is present

Configuration steps on Kibana

  1. Goto : http://localhost:5601 (http://localhost:5601/)
  2. Click on Add APM
  3. Scroll down and click on Check APM Server Status
  4. Scroll down and click on Check agent status
  5. Click on Load Kibana objects
  6. Launch APM

APM is now ready and integrated with the service at this moment. Now try to do some operations on the UI or run some controller tests to see the transaction in APM.


References

โœŒ๏ธ