Skip to content

5. Installing on Containers and Kubernetes

Chapter 3 covered attaching the agent to a WAS installed directly on a server. This chapter covers the case where the WAS runs as a container.

Which Method to Choose

MethodWhat it doesWhen to use it
Baking it into the imageBuild a base image containing the agent and have the application use it as its FROMWhen you manage image builds yourself
S2IPut the agent files in alongside the source and the build packages themWhen developers upload only source and build
Automatic injection (Operator)Just add a label to the workload and the agent goes in automatically. The image is not changedRecommended when using Kubernetes or OpenShift

Automatic injection is covered not here but in the OPENMARU APM Operator User Guide. The image does not have to be touched and the Operator handles upgrades too, so in a Kubernetes environment consider that route first. The two methods below are for when the Operator cannot be used or the image has to be managed directly.


1. Baking the Agent into the Image

To monitor a WAS instance running as a container, an image containing the agent has to be built and registered in a registry. The build and deployment steps are described below.

Preparing the Agent Files

Unpack the file below on a Linux machine that can reach the registry and has Podman installed.

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

Composing the Dockerfile

When building the image, include khan-agent-5.1.0.jar, khan-agent.conf, and user-interceptor.conf.

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 the configuration items in khan-agent.conf, see 4. Environment Variables Available in a Pod below.

Composing build.sh

This is the script that builds the image and pushes it to the registry. The address differs depending on whether the registry is on an external server or runs as a container, so change REGISTRY_URL to suit your environment.

$ vi build.sh
#/bin/bash
# -------------------------------------------------------------
# OPENMARU APM https://www.openmaru.io/
# for OpenShift Container JBoss EAP 7.0 Image Monitoring
#
# contact : service@opennaru.com
# Copyright (c) 2026. OPENMARU, 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

The image's namespace and image stream name are given as openshift/$TAG_NAME:$VERSION, so change them to whatever name you want.

Pushing requires being signed in to the registry. Sign in with oc login or podman login 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

Building and Pushing to the Registry

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

$ ./build.sh

The build passes through the steps from STEP 1 in turn, then the push follows. Only three things need checking.

What to checkWhat appears in the log
Did the agent go into the imageThe ADD ./khan-agent-<version>.zip and ADD khan-agent.conf steps pass without error
Are the startup options baked inENV JAVA_OPTS="-javaagent:…" and ENV JAVA_OPTS="-Dkhan.config.file=…"
Did it reach the registryThe final Writing manifest to image destination and Storing signatures

*/} Using cache … means the previous build result is being reused, which is normal. If the cache is used even after the agent files changed, rebuild with podman build --no-cache.

If it fails, first see which STEP it stopped at. Stopping at an ADD step means the file is not in the build directory; stopping at the push step is a registry sign-in or address problem.

Verifying the Image

After deploying, check that it connects and works in OPENMARU APM.

  1. Check the agent connection
  2. Check JVM monitoring
  3. Check the T-Map when calling /session/index.jsp

If it does not work, check the order of JAVA_OPTS in the process. It has to be in this order.

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

2. Using It in the Application Image

Put the image you built into the FROM clause of the application Dockerfile.

FROM registry.access.redhat.com/jboss-eap-6/eap64-OpenShift

… omitted …

FROM docker-registry-default.ocp-dev.opennaru.com/jboss-eap-6/eap64-OpenShift

… omitted …

Deploying the application with the image built this way makes the instance appear in the console and transactions start flowing. When the instance is visible under WAS > Dashboard, the installation is finished.

How to read the screens and the troubleshooting features (thread dumps, heap analysis) are covered in the user guide.


3. Building with S2I

S2I (Source-to-Image) is an open-source build method that generates a runnable container image from source code alone, used mainly in OPENMARU COP and Red Hat OpenShift. It uses the source-based method by default but also supports the Dockerfile and binary methods. Its advantage is that developers can control the build process directly.

Putting the downloaded khan-agent-5.1.0.zip file in the data directory below deploys it to the /deployments/data directory of the pod.

warning

Depending on the S2I (Source-to-Image) image, the /deployments/data path can differ

project/
├── data/
│ ├── khan-agent-5.1.0.jar # the agent JAR file
│ ├── khan-agent.conf # the agent configuration file
│ └── user-interceptor.conf # the agent configuration file (user interceptor)
└── src/
└── ... # the user application source code
Tip

Even without S2I (Source-to-Image), if you build with a Dockerfile you can include the Agent files with ADD.

Configuration

Info

It can be configured by referring to Agent Configuration per WAS Type.

...
spec:
...
containers:
- resources: {}
name: testapp
env:
- name: OMAPM_HOST
value: 10.20.2.9
- name: OMAPM_PORT
value: '80'
- name: JAVA_TOOL_OPTIONS
value: '-javaagent:/data/khan-agent-5.1.0.jar'
- name: JAVA_OPTS
value: '-Dtest1=1 --add-opens=java.base/...'## omitted
- name: OMAPM_APPLICATION_NAME
value: 'testapp-${HOSTNAME:-:2}'
- name: OMAPM_INSTANCE_ID
value: 'testapp-${HOSTNAME:-:2}-${HOSTNAME:-:3}'
- name: OMAPM_TRANSACTION_TRACE_THRESHOLD
value: '500'

4. Environment Variables Available in a Pod

These are the OPENMARU APM khan-agent.conf configuration items that can be given as environment variables on a Deployment.

SettingDescriptionDefault
OMAPM_APPLICATION_NAMESpecifies the application group name. Note that the build number does not appear either.e.g. when hostname is jboss-eap-egov-65-zs95r, eap-${HOSTNAME:-:5} => eap-65
OMAPM_HOST
OMAPM_PORT443
OMAPM_TLStrue
OMAPM_AGENT_IP
OMAPM_USER_KEYNIL
OMAPM_INSTANCE_IDSpecifies the instance name. When set, it is shown as [OMAPM_INSTANCE_ID value]-build number-random value.
When not set, the Deployment name is used.
e.g. when hostname is jboss-eap-egov-65-zs95r, eap-${HOSTNAME:-:5}-${HOSTNAME:-:6} => eap-65-zs95r
case1: instanceid-${RANDOM:4} ==> instanceid-qfPb
case1: instanceid-${RANDOM:4}-s ==> instanceid-qfPb-s
case1: instanceid-${IPADDR:3} ==> instanceid-23-10 (ip=192.168.23.10)
case1: instanceid-${HOSTNAME:-:2} ==> instanceid-apm (hostname=test-apm)
case1: instanceid-${HOSTNAME:-:2}-${IPADDR:3}-${RANDOM:4}-s ==> instanceid-apm-23.10-afcg-s (hostname=test-apm, ip=192.168.23.10)
OMAPM_AGENT_TYPEWAS
OMAPM_AGENT_COMPRESS_TYPESpecifies the agent's compression algorithm type.lzw (default=snappy)
OMAPM_APDEX_THRESHOLDSpecifies the response time at which the user is satisfied, for APDEX (the default is 3 seconds).3.0
OMAPM_TRANSACTION_TRACE_ENABLEDSpecifies whether to use transaction tracing.true
OMAPM_TRANSACTION_TRACE_THRESHOLDSpecifies the response time above which a transaction trace is collected (in ms). Default: 500 ms500
OMAPM_TRANSACTION_TRACE_THRESHOLD
_UNDER_DETAIL_ENABLED
false
OMAPM_SQL_CAPTURE_ENABLEDSpecifies whether to collect SQL statements during a transaction trace.true
OMAPM_TRANSACTION_TRACE_SQL_PARAMETERIZEfalse
OMAPM_TRANSACTION_SAMPLING_INTERVALSpecifies the transaction collection interval for the same URL. Setting 10 keeps a trace for only 1 in 10 for the same URL.1
OMAPM_TRANSACTION_TRACE_SQL_STACKTRACE
_THRESHOLD
Sets the SQL query stack trace threshold in ms.30000
OMAPM_TRANSACTION_TRACE_HEADER_ENABLEDSpecifies whether header tracing of the request is enabled.true
OMAPM_TRANSACTION_TRACE_HEADER_KEYSThe key values of the request headers
OMAPM_TRANSACTION_TRACE_COOKIE_ENABLEDSpecifies whether cookie tracing of the request is enabled.false
OMAPM_TRANSACTION_TRACE_COOKIE_KEYSThe key values of the request cookiesJSESSIONID
OMAPM_TRANSACTION_TRACE_PARAMETER_KEYSAdds URL parameters
OMAPM_DATABASE_FETCH_WARNINGSPrints a warning when the comma-separated number of rows is fetched from a SQL ResultSet.10000,20000,30000
OMAPM_DATABASE_CONN_LEAK_WARNINGWarning for a shortage of database connectionsfalse
OMAPM_DATABASE_POOL_STAT_ENABLEDSpecifies whether monitoring of overall database pool statistics is enabledfalse
OMAPM_DATABASE_POOL_STAT_INCLUDE_PATTERNSSpecifies the comma-separated list of datasource name patterns to include
OMAPM_DATABASE_POOL_STAT_EXCLUDE_PATTERNSSpecifies the comma-separated list of datasource name patterns to exclude
OMAPM_INCLUDE_PACKAGES
OMAPM_TRANSACTION_EXCLUDE_URL_PATTERNSURLs to exclude from monitoring (regular expression). e.g. /test/test.**,\**/abc/test.*\*
OMAPM_TRANSACTION_EXCLUDE_URL_SUFFIX.gif,.swf,.css,.hwp,.xls,.xlsx,.eot,.pptx,
.ppt,.asf,.pdf,.txt,.flv,.mp3,.mp4,.doc,
.html,.wmv,.jpg,.zip,.wav,.png,.ttf,.mov,
.ico,.js,.woff,.xml,.htc,.NewProxyConnection,
.DelegatingConnection,.SqlSessionTemplate,
.CUBRIDConnection,
.PoolableConnection,.WrappedConnection,
/bea_wls_deployment_internal/DeploymentService,
.GIF,.SWF,.CSS,.HWP,.XLS,.XLSX,.EOT,.PPTX,
.PPT,.ASF,.PDF,.TXT,.FLV,.MP3,.MP4,.DOC,
.HTML,.WMV,.JPG,.ZIP,.WAV,.PNG,.TTF,.MOV,
.ICO,.JS,.WOFF,.XML,.HTC
OMAPM_TRANSACTION_EXCLUDE_URL_SUFFIX_EXCLUDEtrue
OMAPM_TRANSACTION_EXCLUDE_USER_AGENT
_PATTERNS
^openmaru-health-check$
OMAPM_TRANSACTION_ERRORPAGE_URL_PATTERNS/session/force500.\*,/test/test500.*
OMAPM_TRANSACTION_WITH_EXCEPTION_VIEW
_ENABLED
true
OMAPM_TRANSACTION_WITH_EXTERNAL_HTTP
_ERROR_VIEW_ENABLED
true
OMAPM_TRANSACTION_WITH_EXTERNAL_HTTP
_ERROR_CODES
OMAPM_TRAFFIC_CONTROL_ENABLEDtrue
OMAPM_TRAFFIC_CONTROL_PATTERN_1Specifies the maximum number of concurrent requests allowed for the given pattern/test/slow., 100
OMAPM_TRAFFIC_CONTROL_PATTERN_2Specifies the maximum number of concurrent requests allowed for the given pattern/test/test., 100
OMAPM_TRAFFIC_CONTROL.PATTERN_3Specifies the maximum number of concurrent requests allowed for the given pattern/test/TestServlet., 100
OMAPM_UBT_CHECK_ENABLEDfalse
OMAPM_UBT_CHECK_TYPEip
OMAPM_UBT_CHECK_USER_COUNT100
OMAPM_UBT_CHECK_TIME_INTERVAL1
OMAPM_UBT_CHECK_ALERT_DUP_PREVENT30
OMAPM_USER_TRACKING_MODESpecifies the user tracking mode. 0: client IP, 1: the JSESSIONID cookie, 2: the KHANUSER cookie - default2
OMAPM_USER_THINKTIME_MINUTES5
OMAPM_ENABLE_FILTER_INTERCEPTORfalse
OMAPM_ENABLE_IBATIS_INTERCEPTORfalse
OMAPM_ENABLE_MYBATIS_INTERCEPTORfalse
OMAPM_ENABLE_HTTP_INTERCEPTORfalse
OMAPM_ENABLE_SPRINGBATCH_INTERCEPTORfalse
OMAPM_ENABLE_LOGGING_INTERCEPTORfalse
OMAPM_TRACE_LOGGING_LEVELSWARN,ERROR,FATAL
OMAPM_PUSH_TRANSACTION_NO_DELAYtrue
OMAPM_ACTIVEUSER_COUNTFIRSTREQUESTfalse
OMAPM_USER_CHARSET_ENCODINGSpecifies the APM encoding valueUTF-8
OMAPM_USER_INTERCEPTOR_FILEThe name of the file holding the user's interceptor settingsuser-interceptor.conf
OMAPM_LOG_DIRSets the APM log path/svc/test/khan-agent/log
OMAPM_LOG_FILESpecifies the log file namekhan-agent-${INSTANCEID}.log
OMAPM_LOG_LEVELSpecifies the log levelINFO
OMAPM_LOG_BACKUP_INDEXSets how many log backup files to keep3
OMAPM_LOG_ROTATE_SIZESpecifies the log file size at which to rotate10240000
OMAPM_SESSION_MANAGER_ENABLEDWhether the session manager is enabledtrue
OMAPM_ACTIVE_SESSION_COUNT_ENABLEDWhether session counting is enabledtrue
OMAPM_AUDIT_LOG_ENABLEDWhether the audit log file is enabledtrue
OMAPM_AUDIT_LOG_USERIDKEYUSER_ID
OMAPM_AUDIT_LOG_DIRSets the audit log path
OMAPM_AUDIT_LOG_FILENAMESpecifies the audit log file nameaudit-{date: yyyy-MM-dd}.log
OMAPM_AUDIT_LOG_POLICIESdaily: 00:00
OMAPM_AUDIT_LOG_BACKUPSSets how many audit log backup files to keep3