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

    • How to identify and resolve conflicts between other APM products and the APM Insight .NET agent

      Problem statement: You are experiencing either of the below issues and suspect that another APM product is interfering with the Site24x7 .NET agent. 1. The .NET monitor is not created under APM > APM Insight > Applications, even after the .NET agent ...
    • 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 ...
    • Bundled .NET and .NET Core agents in a single MSI

      In APM Insight .NET agent version 6.8.0, the .NET and .NET Core agents have been bundled into a single MSI, enabling unified monitoring of both application types. Upgrade requirements for .NET Core agent 6.7 and below If you're using .NET Core agent ...
    • How to uninstall the Site24x7 Windows Server Monitoring Agent

      Method 1: To uninstall the Site24x7 Windows Server Monitoring Agent, click the link below: https://staticdownloads.site24x7.com/server/Site24x7WindowsAgentUninstall.zip Unzip and execute the Uninstall.bat file in the Command Prompt as an ...
    • Unable to add SQL insight monitor

      If the SQL Insight monitor is not getting added even after entering your credentials, try these troubleshooting steps: Ensure that the Auto-discover applications feature is enabled. If not, you will need to trigger discovery using the Discover ...