Add Node.js agent in Kubernetes via InitContainers (using prebuilt agent image)
To integrate the APM Insight Node.js agent into your Kubernetes applications using InitContainers, follow the steps given below:
Step 1:
Create an empty volume that will be used to copy the agent files during the initContainers process.
Example:
- volumes:
- - name: app-volume
Step 2:
Include the following initContainers command in your helm chart/deployment YAML file.
- initContainers:
- - name: init-npm
- image: site24x7/apminsight-nodejsagent:4.8.0
- imagePullPolicy: IfNotPresent
- command: ['cp', '-r', '/opt/site24x7/.', '/apm']
- volumeMounts:
- - name: app-volume
- mountPath: /apm
Step 3:
Mount the volume created in step 2 into your application container.
Example:
- containers:
- env:
- - name: NODE_OPTIONS
- value: "--require /apm/node_modules/apminsight"
- - name: APMINSIGHT_LICENSE_KEY
- value: "<license-key>"
- - name: APMINSIGHT_APP_NAME
- value: "<application-name>"
- - name: APMINSIGHT_APP_PORT
- value: "<application-port>"
- volumeMounts:
- - mountPath: /apm
- name: app-volume
For applications using the PM2 process manager instead of Kubernetes, enable PM2 support by adding the following in the env section of your deployment YAML:
- - name: APMINSIGHT_PROCESS_MANAGER
- value: "true"
Example YAML deployment file for your reference:
- apiVersion: apps/v1
- kind: Deployment
- metadata:
- name: sample-deployment
- spec:
- replicas: 1
- selector:
- matchLabels:
- app: sample-app
- template:
- metadata:
- labels:
- app: sample-app
- spec:
- initContainers:
- - name: init-npm
- image: site24x7/apminsight-nodejsagent:4.8.0
- imagePullPolicy: IfNotPresent
- command: ['cp', '-r', '/opt/site24x7/.', '/apm']
- volumeMounts:
- - name: app-volume
- mountPath: /apm
- containers:
- - name: main-container
- image: myrepository/sample-nodejs-app:latest
- env:
- - name: NODE_OPTIONS
- value: "--require /apm/node_modules/apminsight"
- - name: APMINSIGHT_LICENSE_KEY
- value: "<license-key>"
- - name: APMINSIGHT_APP_NAME
- value: "<application-name>"
- - name: APMINSIGHT_APP_PORT
- value: "<application-port>"
- volumeMounts:
- - mountPath: /apm
- name: app-volume
- volumes:
- - name: app-volume
- emptyDir: {}
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 ...
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 ...
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 ...
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 ...