12 Install and Configure APM Agents on Containers
APM Java Agent on Docker: Installation and Verification Instructions
To install APM Java Agent in a Docker container:
For an example of APM Java Agent on Docker using Kubernetes, see https://docs.oracle.com/en/solutions/monitor-applications-on-kubernetes/index.html.
APM Node.js Agent on Docker: Installation and Verification Instructions
To set up APM Node.js Agent within a Docker container, follow these additional steps apart from the ones listed in Agent Requirements and Installation Instructions.
-
After you have downloaded the APM Node.js Agent installation software and extracted it, copy the software into your Docker container.
-
Run the provisioning script to install the agent in the container. See Install and Provision APM Node.js Agent.
-
Copy the application files into the container. This is the application that will be monitored by Application Performance Monitoring.
-
Expose the required ports and start your Node.js application.
-
Build the image of the container.
Here’s an example of a docker file ready to install APM Node.js Agent:COPY ./<Stage_DIR>/usr/src/provision ENV NODE_PATH /usr/local/lib/node_modules RUN /bin/bash ProvisionApmNodeAgent.sh -h <host> COPY ./<your application>/usr/src/<application folder> WORKDIR /usr/src/<application folder> EXPOSE 3000 RUN npm -g list --depth=0 CMD [ "npm", "start" ]
-
Spawn a new docker container:
sudo docker run -h <host> -p <port>:3000 -d node-web-app
Note:
The parameter
-h
is essential for the hostname validation to succeed during provisioning the agent. This is required if your container is not able to resolve the/etc/hosts
file. By default, the provisioning script can determine the machine hostname.By using the
-h do-not-use
parameter, you can override this default behavior.
Verifying the Installation
To verify the installation of the APM Node.js Agent in your container:
-
View the list of containers running on the host and get the ID of your container using this command:
sudo docker ps
-
Login to the container using this command:
sudo docker exec -it <container id> /bin/bash
-
Navigate to the
oracle-apm
folder of your application. Check the folder containing thecontainer id
to locate the Agent’s configuration and log folders. Verify the log contents are similar to the agent deployed on any other normal host.
APM Ruby Agent on Docker: Installation and Verification Instructions
Verifying the Installation
To verify the installation of the APM Ruby Agent in your container:
-
Check the
agent_startup.log
file to see if the APM Ruby Agent is running within the container:INFO <CONFIG> OS Container information: type=docker, identity=<long identity of the container>
-
In the
startup.log
, the Host discovery type has two new fields —osContainerType
andosContainerId
.Example25c4188 <2016-04-12T12:26:13:468> INFO <STARTUP> #<OracleAPM::HostInfo:0x0000000411f428 @hostName="myvm.jc", @osName="linux-gnu", @osVersion="", @architecture="x86_64-linux", @processorCount=4, @osContainerType="docker", @osContainerId="<long identity of the container>", @agentIdKey="<agent id>=", @agentVerKey="<agent version key>", @idKey="<identity key>", @verKey="<version key>>