Skip to main content

Installing the Docker environment

This process applies the WhaTap monitoring agent to the Go application running on the Docker container and packages the container image as follows.

Note

EKS Fargate is to be supported later.

Download agent

Install the whatap-agent package when building your Go application docker image.

Red Hat/CentOS
RUN rpm -Uvh https://repo.whatap.io/centos/5/noarch/whatap-repo-1.0-1.noarch.rpm
RUN yum install -y whatap-agent

Agent CONFIG.

Create the whatap.conf file in which WhaTap's access key and server IP address have been set in the user application execution path. If you use a specific path, you can set it with the WHATAP_HOME environment variable.

whatap.conf
RUN echo "accesskey={Access Key}" >> whatap.conf 
RUN echo "whatap.server.host={Collection Server IP Address}" >> whatap.conf
Note

Be careful not to expose the access key to images that are in Docker Public status.

Setting the WHATAP_HOME variable

You can set the whatap.conf path as the WHATAP_HOME variable. Create the WHATAP_HOME path first. Add the WHATAP_HOME setting before the application startup command.

mkdir ./whatap_home
echo "license={Access Key}" >> ./whatap_home/whatap.conf
echo "whatap.server.host={Collection Server IP Address}" >> ./whatap_home/whatap.conf

# run application
WHATAP_HOME=./whatap_home ./app

Configuring the Go library

Add the github.com/whatap/go-api package to the Go application source code.

go get github.com/whatap/go-api

Configure for initialization and shutdown with the trace.Init() and trace.Shutdown() functions. Set the startup and end for transactions with the trace.Start() and trace.End() functions.

Go
import "github.com/whatap/go-api/trace"

func main(){
trace.Init(nil)
//It must be executed before closing the app.
defer trace.Shutdown()

ctx, _ := trace.Start(context.Background(), "Start Tx")

...

trace.End(ctx, err)
}
Note

For more information about the library configuration, 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}}

See the following example:

apiVersion: v1
kind: Pod
metadata:
name: # Pod Name
labels: # Pod Labels
spec:
containers:
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}}
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.

Running the agent

Add the whatap-agent startup command before the application startup command.

sh -c "/usr/whatap/agent/whatap-agent start && [application startup command]"

Execute the following command to check whether the WhaTap service has been run normally. When the application server runs, it begins collecting monitoring information.

ps -ef | grep whatap_agent

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_agent in the container, and then check whether the agent options have been applied properly.

  • Check the WHATAP_HOME/logs of the container or the logs directory of the application execution path. The file name of the agent log is displayed as logs/{boot or install}-yyyymmdd.log.