Site24x7 APM Insight Java agent setup in K8s via Persistent Volumes

Site24x7 APM Insight Java agent setup in K8s via Persistent Volumes

This document explains how to setup the APM Insight Java agent for applications running in Kubernetes 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 Site24x7 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 Site24x7 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 Site24x7 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='your_s247_license_key' -n petclinic
    Replace app-secret, s247_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.
    1. If the license key is provided in the apminsight.conf file, ignore this step.
      Name: S247_LICENSE_KEY 
      Value: s247licensekey from the secret added in step 1. 
    2. 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:/opt/apm/apminsight-javaagent.jar -Dapminsight.application.name=Petclinic -Dapminsight.log.dir=/home/apm"

  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"


    • Related Articles

    • APM Insight integration for Next.js in Kubernetes

      To integrate the Site24x7 APM Insight Next.js agent into your Kubernetes application using initContainers with the prebuilt agent image, follow the steps below: Prerequisites A Next.js application container image The Site24x7 APM Insight license key ...
    • Accessing products via Site24x7

      You can seamlessly access ManageEngine CloudSpend and Site24x7’s sub-products, like Digital Risk Analyzer, StatusIQ, and Toolset, from within your Site24x7 web client. The product switcher , available at the top-right corner of the interface, lets ...
    • Where are Site24x7's physical data storage regions located?

      Site24x7's integrated data centers are located in the US, European Union, India, China, Australia, and Japan. All Site24x7 customer-related data are stored in these physical storage regions. Data Center Primary Data Center Disaster Recovery Data ...
    • Troubleshoot the Error 404 and Error 99 for RabbitMQ

      When installing the RabbitMQ plugin, you may encounter the following errors: HTTP Error 404: Not Found: This error usually occurs when Site24x7's RabbitMQ monitoring plugin attempts to access the /api/overview page of RabbitMQ, but the resource ...
    • Exclude Site24x7 monitoring traffic from Google Analytics

      You can exclude traffic from the Site24x7 Web Transaction (Browser) monitor and Webpage Speed (Browser) traffic from Google Analytics in two ways. To exclude traffic for the Web Defacement monitor, you can follow the first method. 1. Creating a ...