Monitor your Java Apps Elastic APM Aravind Putrevu| Dev Adv | Elastic aravind.dev | @aravindputrevu

What’s Up 2 ● The Stack ● What is APM? ● Why APM? ● What it can do? ● Demo

Elastic Stack SOLUTIONS Elastic Stack Kibana Visualize & Manage Elasticsearch Store, Search, & Analyze Beats SaaS Elastic cloud 3 Logstash SELF-MANAGED Elastic cloud Enterprise Standalone Ingest

Solutions Elastic Stack Logging Metrics APM Security Analytics App Search Site Search Enterprise Search Business Analytics FUTURE Kibana Visualize & Manage Elasticsearch Store, Search, & Analyze Beats SaaS Logstash SELF-MANAGED Ingest

What is APM? In the fields of information technology and systems management, application performance management (APM) is the monitoring and management of performance and availability of software applications. APM is “the translation of IT metrics into business meaning ([i.e.] value).” -Wikipedia 5

6

.. and when this happens… 7

you open these… 8

9

10

What is APM? Application Performance Monitoring 11

Why APM? • APM records traces for database queries, external HTTP requests, and other slow operations that happen during requests to your application ‒ easier to see where your application is spending time • It collects not handled errors and exceptions ‒ easier to debug errors • • 12 Find performance bottlenecks and errors before your customers face them Increase the productivity of your development team

● 100% Open Source ● Readymade UI in Kibana ● Language Agents alpha 13 beta

How it works

Elastic APM Terminology • Service ‒ Set in the APM agent configuration to identify a particular group of APM agents as a single service, a way to logically identify a group of transactions. • Transaction ‒ The requests and responses that compose a service, e.g. the login API call, each made up of individual spans. • Span ‒ A single event within a Transaction such as a Method call, Database query, or Cache insert or retrieval, i.e. anything that takes time to complete. • Errors ‒ Groups of exceptions with matching exception or log messages. 15

Elastic APM Terminology Transaction, trace & span 16

Distributed Tracing 17

APM conceptual allegory Fence jump service: Transaction: 6.5 seconds • • • • 18 fence 1: 1 second fence 2: 2 seconds fence 3: 2 seconds fence 4: 2.5 seconds

APM conceptual allegory Fence jump service: Transaction: 1 second • 19 fence 1 - 1 second and error captured

How to instrument java apps?

  • javaagent java -javaagent:/path/to/elastic-apm-agent-<version>.jar -Delastic.apm.service_name=my-cool-service \ -Delastic.apm.application_packages=org.example,org.another.example -Delastic.apm.server_urls=http://localhost:8200 \ -jar my-application.jar
    20 \

How to instrument java apps?

  • apm-agent-attach.jar java -jar apm-agent-attach.jar —pid <pid> [—args <agent_arguments>] 21

How to instrument java apps? - Programmatic Attach <dependency> <groupId>co.elastic.apm</groupId> <artifactId>apm-agent-attach</artifactId> <version>${elastic-apm.version}</version> </dependency> ElasticApmAttacher.attach(); service_name=my-cool-service application_packages=org.example,org.another.example server_urls=http://localhost:8200 22

How it is working? Simple! Byte-code manipulation 23

What APM can do? 24 • Monitor your application • Trace your code • Reduce overall debugging time

Elastic Cloud {X} Application

Azure/GCP/AWS X Language Application in AKS/GKE/EKS

Elasticsearch on Kubernetes Cluster Any language Application

What you can’t do with APM? • Infrastructure Monitoring • Log analytics • Detect Security Attacks

How Elastic Stack can help you? 29

30

References • https://github.com/elastic/apm-server • https://github.com/elastic/opbeans-java • https://www.elastic.co/webinars/elasticsearch-apm-overview • https://discuss.elastic.co/c/apm ela.st/java-apm bit.ly/learnK8s

Fin! @aravindputrevu