Skip to main content

Installing Docker Java

At the bottom of Management > Agent installation, click Install Application > Select the Docker Java tab in Install guide.

This process adds the settings for applying the agent to the JVM option of the Java application running on the Docker container and packages the container images as follows:

Note
  • EKS Fargate is to be supported later.

  • Git example code is provided to help you understand the Java application integration process. See the following.

Download agent

To install the WhaTap application agent, create the whatap.conf file. Change {YOUR_PROJECT_ROOT} to the top-level path of the project to install the agent.

cat >{YOUR_PROJECT_ROOT}/whatap.conf <<EOL
whatap.server.host={proxyServer}
EOL
Note

The whatap.conf file can be managed using the ConfigMap function in the user Kubernetes environment.

The following guides you to include the latest version of the agent in the application image.

  1. To include the WhaTap agent in the application image, add the following in the Dockerfile's final image build step. Change {YOUR_PROJECT_ROOT} to the top-level path of the project to install the agent.

    # Create the WhaTap agent directory in the user container
    RUN mkdir -p /whatap

    # Copy the WhaTap Java agent to the user container
    COPY --from=whatap/kube_mon /data/agent/micro/whatap.agent.kube.jar /whatap

    # Copy the created whatap.conf file to the user container
    COPY {YOUR_PROJECT_ROOT}/whatap.conf /whatap/
  2. Add the following to the startup command of Dockerfile.

    -javaagent:/whatap/whatap.agent.kube.jar -Dwhatap.micro.enabled=true

    See the following definition example of the following Dockerfile.

    Dockerfile
    FROM openjdk:8-jdk-slim
    RUN mkdir -p /app && mkdir /whatap
    WORKDIR /app
    COPY --from=whatap/kube_mon /data/agent/micro/whatap.agent.kube.jar /whatap
    COPY ./whatap.conf /whatap
    COPY ./target/myApp.jar /app/
    CMD ["java","-javaagent:/whatap/whatap.agent.kube.jar","-Dwhatap.micro.enabled=true","-jar","/app/myApp.jar"]
    EXPOSE 8080
  3. Build the Docker. Change {YOUR_DOCKERFILE_DIR} to the path where Dockerfile is located.

    cd {YOUR_DOCKERFILE_DIR}
    docker build -t {IMAGE_NAME} .
Tip

For Java 17 or later, add the --add-opens=java.base/java.lang=ALL-UNNAMED option related to the reflection.

Setting the security key

Set a security key to query SQL variables and perform HTTP queries, or use the Thread stop function.

  • Java Agent 2.2.2 or later

    After creating the security.conf file in the $WHATAP_HOME path, enter a 6-character password consisting of alphabets and numbers as follows:

    security.conf
    paramkey=ABCDEF # SQL variable and HTTP query lookup
    threadkill=ABCDEF # Thread stop function
  • Java agent 2.2.2 or earlier

    After creating the paramkey.txt file in the $WHATAP_HOME path, enter a 6-character password consisting of alphabets and numbers as follows:

    paramkey.txt
    ABCDEF # SQL variable and HTTP query lookup, thread stop function
Tip

When updating the Java agent version to 2.2.2, the key values in the existing paramkey.txt file are automatically applied to the security.conf file. For example, if you used FEDCBA in paramkey.txt and updated to the version 2.2.2, it is applied to the security.conf file as follows:

paramkey=FEDCBA
threadkill=FEDCBA

If the paramkey.txt file does not exist, the key value of the security.conf file is automatically created as the key value of WHATAP.

Note
  • For agent settings related to recording SQL parameters, see the following.

  • For agent settings related to recording the HTTP parameters, see the following.

Configuring the container environment variables

After building Docker, set container environment variables in the Kubernetes environment. Add the following items in the yaml file for releasing the application.

env:
- name: NODE_IP
valueFrom: {fieldRef: {fieldPath: status.hostIP}}
- name: NODE_NAME
valueFrom: {fieldRef: {fieldPath: spec.nodeName}}
- name: POD_NAME
valueFrom: {fieldRef: {fieldPath: metadata.name}}
- name: OKIND
value: {YOUR_OKIND_NAME}
- name: license
value: {licenseKey}
- name: whatap_server_host
value: {proxyServer}
- name: whatap_micro_enabled
value: "true"

See the following example:

apiVersion: apps/v1
kind: Deployment
metadata:
name: #DeploymentName
labels:
app: #AppLabel
spec:
replicas: 3
selector:
matchLabels:
app: #AppLabel
template:
metadata:
labels:
app: #AppLabel
spec:
containers:
- name: #ContainerName
image: nginx
ports:
- containerPort: 80
env:
- name: NODE_IP
valueFrom: {fieldRef: {fieldPath: "status.hostIP"}}
- name: NODE_NAME
valueFrom: {fieldRef: {fieldPath: "spec.nodeName"}}
- name: POD_NAME
valueFrom: {fieldRef: {fieldPath: "metadata.name "}}
- name: OKIND
value: #DeploymentName
- name: license
value: #licenseKey
- name: whatap_server_host
value: #proxyServer
- name: whatap_micro_enabled
value: "true"
Note

Roles of environment variables

  • NODE_IP: Collects the IP address of the node where the current Pod has been hosted.

  • NODE_NAME: Collects the name of the node where the current Pod is running.

  • POD_NAME: Collects the name of the current Pod.

  • OKIND (optional): Groups applications for Pods. If set to a deployment name, the corresponding Pods are grouped together.

  • license: Key for agent authentication.

  • whatap_server_host: Host IP of the WhaTap collection server

  • whatap_micro_enabled: Enables integration with containers.

Checking the agent installation

  • To check whether the agent has been installed, go to Dashboard > Application Service Dashboard.

  • If you have manually installed the downloaded file but cannot see the agent in Dashboard, check the following.

    • Execute the command, ps -ef | grep whatap in the container, and then check whether the agent options have been applied properly.

    • Check the content of the container in the /whatap/logs path. Agent logs are output in the format of logs/{whatap configuration file name}-yyyymmdd.log.