APM Insight Java agent setup in K8s via Persistent Volumes

APM Insight Java agent setup in K8s via Persistent Volumes

Prerequisites

1. A persistent volume (with a capacity of 100mb).
2. The persistent volume mounted on all deployment pods (via persistent volume claim).
3. The Applications Manager APM Insight Java agent zip file was downloaded, moved, and extracted to this volume.
Note: You can download the agent zip file from this link.
4. Add the Applications Manager license key (copied from our web client) to the apminsight.conf file, if you wish to keep it as a secret, skip this step.
5. If there is any proxy connection, provide the proxy details in the apminsight.conf file

Instructions

1. If you have provided the Applications Manager license key in the apminsight.conf file, you can skip this step. Otherwise, include it in the application secrets file.
Example:
kubectl create secret generic app-secret --from-literal=s247licensekey='AppManager_license_key' -n petclinic
Replace app-secret, AppManager_license_key, and namespace petclinic with the appropriate values.
2. You must include the following two environment variables in the application deployment YAML file as shown.If the license key is provided in the apminsight.conf file, ignore this step.

      a. Name: S247_LICENSE_KEY           
          Value: s247licensekey from the secret added in step 1.
      b. Name: JAVA_TOOL_OPTIONS
          Value: "-javaagent:[mount/path]/apminsight-javaagent.jar -Dapminsight.application.name=[DesiredMonitorName] -apminsight.log.dir=/home/apm"

In this step, we configure the arguments that the application (Java process) will use during startup, and the agent to report data to the specified monitor name and agent logs to be written to the path /home/apm.

Example 
env:
- name: S247_LICENSE_KEY
  valueFrom:
    secretKeyRef:
      name: app-secret
      key: s247licensekey
- name: JAVA_TOOL_OPTIONS
  value: "-javaagent:[mount/path]/apminsight-javaagent.jar -Dapminsight.application.name=[DesiredMonitorName] -apminsight.log.dir=/home/apm"

Note:
  1. If the agent jar file (apminsight-javaagent.jar) is not available during application startup, the pod creation will fail.
  2. The agent update must be done manually with this method.

Sample Kubernetes Deployment YAML file

apiVersion: v1
kind: Namespace
metadata:
  name: petclinic
---

apiVersion: v1
kind: PersistentVolume
metadata:
  namespace: petclinic
  name: agent-storage
spec:
  capacity:
    storage: 50Mi
  storageClassName: standard
  accessModes:
    - ReadWriteOnce
  persistentVolumeReclaimPolicy: Retain
  hostPath:
    path: "/opt/apm"
---

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  namespace: petclinic
  name: agent-pvc
spec:
  storageClassName: standard
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 50Mi
---

apiVersion: apps/v1
kind: Deployment
metadata:
  namespace: petclinic
  name: petclinic-deployment
spec:
  replicas: 2
  selector:
    matchLabels:
      app: petclinic
  template:
    metadata:
      labels:
        app: petclinic
    spec:
      volumes:
      - name: agent
        persistentVolumeClaim:
          claimName: agent-pvc
      containers:
      - name: petclinic
        image: petclinic:2.5
        ports:
        - containerPort: 8080
        volumeMounts:
        - name: agent
          mountPath: /opt/apm/
        env:
        - name: S247_LICENSE_KEY
          valueFrom:
            secretKeyRef:
              name: app-secrets
              key: s247license
        - name: JAVA_TOOL_OPTIONS
          value: "-javaagent:/opt/apm/apminsight-javaagent.jar -Dapminsight.application.name=Petclinic -Dapminsight.log.dir=/home/apm"

                    New to ADSelfService Plus?

                      • Related Articles

                      • Adding APM Insight Java agent in a Kubernetes environment

                        There are three methods for installing the APM Insight Java agent in a Kubernetes environment. Using Dockerfile Using InitContainers Using Persistent Volumes Prerequisites Download the latest APM Insight Java agent (apminsight-javaagent.zip) file. ...
                      • How to add an APM Insight Java agent in Kubernetes via InitContainers?

                        Step 1. Create a secret to access the APM Insight license key in your application namespace: kubectl create secret generic app-secret --from-literal=s247licensekey='your_APMInsight_license_key' -n petclinic The license key can be obtained from the ...
                      • Self monitor Applications Manager using APM Insight Java Agent

                        Applications Manager is built with Java, hence we can monitor it using APM Insight Java Agent to measure it's performance continuously, which can be very much useful. Setting up APM Insight Java Agent Follow the below steps to download and set up the ...
                      • How to rename an existing APM - Java agent application's monitor?

                        In Applications Manager's APM(Application Performance Monitoring) doesn't support renaming applications/monitors from the web client. However, the application name of an existing application instance can be renamed in the `apminsight.conf` file and ...
                      • Uninstrumented Block of Code - APM Insight

                        In the traces tab --> Slowest Method Calls and Count we show if you find Un-instrumented block of code the reason is as follows: Basically, What is un-instrumented block of code in APM Insight? By default, APM Insight agent monitors known frameworks ...