12 Install and Configure APM Agents on Containers

APM Java Agent on Docker: Installation and Verification Instructions

Reference topic:

To install APM Java Agent in a Docker container:

  1. Install the desired application server on the container.
  2. Provision APM Java Agent in the container.
    ProvisionApmJavaAsAgent.sh -h do-not-use

    By default, the provisioning script can determine the machine hostname. By using the -h do-not-use parameter, you can override this default behavior and delay hostname determination until the application server starts up. Any value other than do-not-use will hardcode a hostname which it's typically undesirable for a container environment. An exception might be if there is a one-to-one mapping between apm agents with an assigned hostname and app server listen ports.

  3. Modify the startup script of your application server to include the -javaagent property.
  4. Build the image of the container.
  5. Within the container, run the application and Application Performance Monitoring to monitor the performance of the application.

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.

  1. After you have downloaded the APM Node.js Agent installation software and extracted it, copy the software into your Docker container.

  2. Run the provisioning script to install the agent in the container. See Install and Provision APM Node.js Agent.

  3. Copy the application files into the container. This is the application that will be monitored by Application Performance Monitoring.

  4. Expose the required ports and start your Node.js application.

  5. 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" ]
  6. 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:

  1. View the list of containers running on the host and get the ID of your container using this command:

    sudo docker ps
  2. Login to the container using this command:

    sudo docker exec -it <container id>  /bin/bash
  3. Navigate to the oracle-apm folder of your application. Check the folder containing the container 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:

  1. 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>
  2. In the startup.log, the Host discovery type has two new fields — osContainerType and osContainerId.

    Example
    25c4188 <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>>