The following describes the procedure.

4.2 Build the APM Agent OpenShift image

Author

Version

Date

Woo, Jangsik, Ryu, Youngjun

v1.1

2021-09-01

To monitor a WAS instance running as a Container on OpenShift in APM, you need to build a Docker Image and register it in OpenShift’s Docker Registry.
The following describes the procedure.

Configure the OpenShift agent file

On a Linux machine with access to OpenShift’s registry and the Podman daemon installed, unzip the following files.

$ wget https://cloud.openmaru.io/api/v1/projects/{SAAS_PROJECT_ID}/download/was-agent.zip
$ unzip khan-agent-5.1.0.zip

Configure the Dockerfile

Add khan-agent-5.1.0.jar, khan-agent.conf, and user-interceptor.conf when creating an image for OpenShift.

FROM registry.redhat.io/jboss-eap-7/eap74-openjdk8-openshift-rhel7

USER root

ENV JAVA_OPTS="-javaagent:/opt/eap/khan-apm/khan-agent-5.1.0.jar"
ENV JAVA_OPTS="-Dkhan.config.file=/opt/eap/khan-apm/khan-agent.conf"

ADD ./khan-agent-5.1.0.zip /opt/eap/
RUN unzip -q /opt/eap/khan-agent-5.1.0.zip -d /opt/eap/khan-apm && \
    chmod -R 777 /opt/eap/khan-apm

ADD khan-agent.conf /opt/eap/khan-apm
ADD user-interceptor.conf /opt/eap/khan-apm

USER jboss

For more information about the khan-agent.conf file, see https://docs.openmaru.io/docs/containerAgentInstall/05.chap/05.html [Pod-enabled environment variables] in the list of container Agent installation guides.

Configure build.sh

The build.sh file contains the scripts to build the image and push it to OpenShift’s Private Registry.
Rename the REGISTRY_URL in the build.sh file, as there are different ways to use the OpenShift Private Registry, such as using it for external servers or as a Container.

$ vi build.sh
#/bin/bash
# -------------------------------------------------------------
# openmaru apm http://www.opennaru.com/
# for OpenShift Container JBoss EAP 7.0 Image Monitoring
# for OpenShift Container
# contact : service@opennaru.com
# Copyright(C) 2015, Opennaru,Inc. All Rights Reserved.
# -------------------------------------------------------------

#/bin/bash
export REGISTRY_URL=default-route-openshift-image-registry.apps.ocp.opennaru.com

TAG_NAME=eap74-test
VERSION=5.1.0-7.1.1
#]
# registry login examples
#.

#oc login
#docker login -u devadmin -p $(oc whoami -t) $REGISTRY_URL
#podman login -u $(oc whoami) -p $(oc whoami -t) $REGISTRY_URL

#sudo docker login -p <TOKEN_IN_OPENSHIFT_REGISTRY> -e unused -u unused $REGISTRY_URL
#oc login --token <TOKEN_IN_OPENSHIFT_REGISTRY> ocp-master1.ocp-dev.opennaru.com

podman build --rm --tag=$TAG_NAME .

podman tag $TAG_NAME $REGISTRY_URL/openshift/$TAG_NAME:$VERSION
#$podman push $REGISTRY_URL/openshift/$TAG_NAME:$VERSION
podman push --tls-verify=false $REGISTRY_URL/openshift/$TAG_NAME:$VERSION

Note that the Docker Image’s NameSpace and Image Stream are named OpenShift/$TAG_NAME:$VERSION, so you can change them to whatever you want.

To build and push to the registry, you need to log in to the registry, so log in with the oc login or podman login command before building.

$ export REGISTRY_URL=**default-route-openshift-image-registry.apps.ocp.opennaru.com**

oc login
Or $ podman login -u devadmin -p $(oc whoami -t) $REGISTRY_URL

Build Docker Image and Push Registry

Run the ./build.sh command to build and push the image.

[root@bastion test1]# *./build.sh*
STEP 1: FROM registry.redhat.io/jboss-eap-7/eap74-openjdk8-openshift-rhel7
STEP 2: USER root
--> Using cache a50cb975c41deb224f7b80554b803052c296d299613e28a1f03dad092c59d643
STEP 3: ENV JAVA_OPTS="-javaagent:/opt/eap/khan-apm/khan-agent-5.1.0.jar"
--> Using cache bc0de1b934a9cced9158f822bdc523e7357e146855f1e931cf0a3107e5809d6a
STEP 4: ENV JAVA_OPTS="-Dkhan.config.file=/opt/eap/khan-apm/khan-agent.conf"
--> Using cache 049c9899bd8bf0c58d62e6e0ae8e937e9d7dd389e0fdf1186297c71c1318f763
STEP 5: ADD ./khan-agent-5.1.0.zip /opt/eap/
--> Using cache ae0554d55338651a58e127f4b2c1a404f1fae7969f2d4f85853380d1417f6176
STEP 6: RUN unzip -q /opt/eap/khan-agent-5.1.0.zip -d /opt/eap/khan-apm && chmod -R 777 /opt/eap/khan-apm
--> Using cache 422ec3534a9c06c4c04d6dca46a18cbaebceb72f6c0f4b0a3c7ae358f420212f
STEP 7: ADD khan-agent-5.1.0.jar /opt/eap/khan-apm
--> Using cache dad9501724490dafe4c8daadef0bed99060b34f69f7ab2199dc3e5f37c603c60
STEP 8: ADD khan-agent.conf /opt/eap/khan-apm
--> Using cache b9378c22e39f55c60c1c9f59a475ca6a9e5ddba577eec85a1b84d4a9563e90c1
STEP 9: ADD user-interceptor.conf /opt/eap/khan-apm
--> Using cache ec08353950d87273d0ac05fabff9aa9063b67ed1e64cd615f9d76f05cec0f224
STEP 10: USER jboss
--> Using cache ad2953319f2eb69f5f0e072f1514dd72d83f667bd4807168adf26c1ba9961900
STEP 11: COMMIT eap74-test
ad2953319f2eb69f5f0e072f1514dd72d83f667bd4807168adf26c1ba9961900
ad2953319f2eb69f5f0e072f1514dd72d83f667bd4807168adf26c1ba9961900
Getting image source signatures
Copying blob 28a63be9d2b0 done
Copying blob d782d20c8ee3 done
Copying blob c8f02e541067 done
Copying blob 132ca6509b35 skipped: already exists
Copying blob 85b07cb63121 skipped: already exists
Copying blob 1eaba82ed886 skipped: already exists
Copying blob b88369a48dc4 done
Copying blob 6d7fcfc12225 done
Copying config ad2953319f done
Writing manifest to image destination
Writing manifest to image destination
Storing signatures

Verify APM Base Image

Deploy to OpenShift and then validate in APM

  1. Verify Agent Access

  2. Check JVM monitoring .

  3. Check T-Map when calling /session/index.jsp

What to do if you encounter an issue

When looking up a process, JAVA_OPTS must be in the following order. OpenShift Terminal

ps -ef | grep jboss

...Omitted...
-javaagent:/opt/eap/khan-apm/khan-agent/khan-agent-5.1.0.jar

...Omitted...

-Xbootclasspath/p:...Omitted...

...Omitted...

-Djava.util.logging.manager=org.jboss.logmanager.LogManager