Adding APM Insight Node.js agent in Kubernetes via InitContainers
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:latest
- 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
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:latest
- 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
Adding APM Insight Java agent in Kubernetes via InitContainers
Step 1: Create a secret for the Site24x7 license key in your application namespace. You can obtain the license key from your site24x7 account by navigating to Admin > Developer > Device Key. Example: kubectl create secret generic app-secret ...
DC migration steps for APM Insight agents
For Server based installations 1. Obtain the new device key. 2. Update the license.key value in the APM Insight configuration file (or the environment variable mentioned) with the new device key. The location varies for each agent, as listed below: ...
DC migration steps for APM Insight Node.js agent
Obtain the new device key. Update the licenseKey value in the apminsighnode.json file located at the <application root directory>. Log in to the server and delete the existing instance information file apminsight.json located at <application root ...
How to add APM Insight Java agent without application restart?
In general, after installing the APM Insight Java agent, you have to restart your application for the agent to capture monitoring data. But in case of critical issues in the app, like sudden application slowness, where you haven't installed APM ...
APM Insight agent log paths
Folder path to view One agent logs One agent logs can be found only in the common application folder in Windows (usually under C:\ProgramData from Vista onwards). Check the following folder path in Windows: C:\ProgramData\Site24x7APMOneAgent\Logs ...