Installing the Docker environment
This process applies the WhaTap monitoring agent to the PHP application running on the Docker container and packages the container image as follows.
Download agent
Install the whatap-php package when building your PHP application docker image.
- x64
- AArch64
RUN wget https://s3.ap-northeast-2.amazonaws.com/repo.whatap.io/alpine/x86_64/whatap-php.tar.gz
RUN tar -xvzf whatap-php.tar.gz -C /
RUN wget https://s3.ap-northeast-2.amazonaws.com/repo.whatap.io/alpine/aarch64/whatap-php.tar.gz
RUN tar -xvzf whatap-php.tar.gz -C /
Agent CONFIG.
-
Use the following command to set the installation script. If you enter the WhaTap access key and server IP, the PHP environment data is automatically collected.
RUN (echo "[Access Key]"; echo "[Server IP]")|/usr/whatap/php/install.sh
-
Using the following method, you can directly enter the PHP environment settings.
# RUN /usr/whatap/php/install.sh -l [Access Key] -s [Server IP] -v [PHP version x.x] -i [php.ini full path] -p [Process Name] -z [thread safety]
RUN /usr/whatap/php/install.sh -l xxxxx -s 1.1.1.1/2.2.2.2 -v 7.0 -i /etc/php.ini -p httpd [-z]
Be careful not to expose the access key to images that are in Docker Public status.
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}}
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
- Command
- Supervisor
Add the whatap-php startup command before the application startup command.
sh -c "/usr/whatap/php/whatap-php start && [Application Startup Command]"
In case of starting the application as supervisor, see the following code to add the whatap-php service.
RUN echo "[program:whatap-php]" >> /etc/supervisor/conf.d/whatap.conf
RUN echo "command = sh -c ‘/usr/whatap/php/whatap-php start’" >> /etc/supervisor/conf.d/whatap.conf
RUN echo "user = root" >> /etc/supervisor/conf.d/whatap.conf
RUN echo "startsecs = 0" >> /etc/supervisor/conf.d/whatap.conf
RUN echo "autostart = true" >> /etc/supervisor/conf.d/whatap.conf
RUN echo "autorestart = false" >> /etc/supervisor/conf.d/whatap.conf
RUN echo "stdout_logfile = /dev/stdout" >> /etc/supervisor/conf.d/whatap.conf
RUN echo "stdout_logfile_maxbytes=0" >> /etc/supervisor/conf.d/whatap.conf
RUN echo "stderr_logfile = /dev/stderr" >> /etc/supervisor/conf.d/whatap.conf
RUN echo "stderr_logfile_maxbytes=0" >> /etc/supervisor/conf.d/whatap.conf
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_php
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 /usr/whatap/php/logs path. The file name of the agent log is displayed as logs/
{boot or install}
-yyyymmdd.log.