This cookbook shows how to setup APM agentless for Java (the APM Java agent library for Linux) with auto-instrumentation on a Java app.
The demo app is the famous Java Community application called Spring PetClinic Microservices, same app used in the Cookbook 102: OpenTelemetry quickstart. The app is composed of multiple services that run in containers, like Config, Discovery Server, Customers, Vets, Visits and API.
Here, the APM agent is injected in each service, enabling automatic instrumentation and performance monitoring.
- an APM account (SaaS)
- a Docker host, for example Docker Desktop
Navigate to the APM webconsole url (for example https://apm.myaccount.aternity.com) > AGENTS > Install Agents:
- Find your CustomerID, for example 12341234-1234-1234-1234-123456789abc
- Grab SaaS Analysis Server Host, for example agents.apm.myaccount.aternity.com
- Obtain the psockets host name replacing agents with psockets, for example psockets.apm.myaccount.aternity.com
- Download the package APM Agentless Instrumentation (Java) (also available on Riverbed support, for example aternity-apm-jida-linux-12.19.0_BL516
Download a local copy of the file docker-compose.yml, for example right-click here to download and save it in the directory Tech-Community/201-instrument-java-microservices-with-apm-agentless
In the docker-compose.yml, for each service, the auto-instrumentation configuration consists in few environment variables set with CustomerID and SaaS Analysis Server Host psockets endpoint, and a volume that mounts the agent.
cool-java-service:
image: myapp/cool-java-service
entrypoint: ["java", "-jar", "MyCoolService.jar"]
environment:
- JAVA_TOOL_OPTIONS=-agentpath:/agent/lib/libAwProfile64.so
- RVBD_ANALYSIS_SERVER=${RIVERBED_APM_SAAS_SERVER_HOST}
- RVBD_CUSTOMER_ID=${RIVERBED_APM_CUSTOMER_ID}
- RVBD_AGENT_FILES=1
- RVBD_APP_INSTANCE=cool-java-service
volumes:
- ./agent:/agent
The CustomerID and SaaS Analysis Server Host can be defined manually, replacing RIVERBED_APM_SAAS_SERVER_HOST and RIVERBED_APM_CUSTOMER_ID directly in the file like this:
cool-java-service:
image: myapp/cool-java-service
entrypoint: ["java", "-jar", "MyCoolService.jar"]
environment:
- JAVA_TOOL_OPTIONS=-agentpath:/agent/lib/libAwProfile64.so
- RVBD_ANALYSIS_SERVER=psockets.apm.myaccount.aternity.com
- RVBD_CUSTOMER_ID=12345678-abcd-1234-abcd-123456789012
- RVBD_AGENT_FILES=1
- RVBD_APP_INSTANCE=cool-java-service
volumes:
- ./agent:/agent
Open a shell
Go in the folder where you keep the docker-compose.yml file you just configured. For example:
cd Riverbed-Community-Toolkit/APM/201-instrument-java-microservices-with-apm-agentless
Unzip the zip archive of the APM Java Agent package, it will be expanded in a subdirectory /agent
unzip aternity-apm-jida-linux-xx.x.x_BLxxx.zip
Start the containers:
docker-compose up
Browse http://localhost:8080 and click around to generate load and transactions that will be monitored by APM
View the entire applications:
Search transactions:
View transaction details:
Press CTRL + C in the shell where it is running.
Or in a shell, go to the folder where you keep the docker-compose.yml and run:
docker-compose down
Please visit Riverbed APM
Copyright (c) 2022 Aternity. The contents provided here are licensed under the terms and conditions of the MIT License accompanying the software ("License"). The scripts are distributed "AS IS" as set forth in the License. The script also include certain third party code. All such third party code is also distributed "AS IS" and is licensed by the respective copyright holders under the applicable terms and conditions (including, without limitation, warranty and liability disclaimers) identified in the license notices accompanying the software.