Customizing the stand-alone Node.js data collector for Kubernetes applications

You can add environment variables to the deployment yaml file to customize the monitoring for your Kubernetes application.

User-defined environment variables for the Node.js data collector

You can use the information in the following table to customize Node.js monitoring on Kubernetes.

Table 1. Supported user-defined environment variables for Node.js monitoring on Kubernetes
Variable name Importance Value Description
KNJ_SAMPLING Optional Sampling count of requests The number of requests based on which a sample is taken.

The default value is 10, which means that one out of every 10 requests is monitored.

If you do not set this variable, the default value 10 is used.

KNJ_MIN_CLOCK_TRACE Optional Response time threshold for collecting method trace, in milliseconds If the response time of a request instance exceeds the value of this variable, the data collector collects its method trace.

The default value is 0.

If you do not set this variable, the default value 0 is used.

KNJ_MIN_CLOCK_STACK Optional Response time threshold for collecting stack trace, in milliseconds If the response time of a request instance exceeds the value of this variable, the data collector collects its stack trace.

The default value is 0.

If you do not set this variable, the default value 0 is used.

KNJ_ENABLE_METHODTRACE Optional
  • True
  • False
Enables or disables method trace.
  • If you set this variable to true, method trace for requests is disabled.
  • If you set this value to false, method trace for requests is enabled. This is the default value.

If you do not set this variable, the default value False is used and method trace for requests is enabled.

KNJ_ENABLE_DEEPDIVE Optional
  • True
  • False
If you set this variable to true, then the diagnostic data is sent to the server. By default, this value is set to false, which means that diagnostic data is not sent to the server.
KNJ_ENABLE_TT Optional
  • true
  • false
Enables or disables the transaction tracking of AAR.
  • If you set this variable to true, transaction tracking of AAR is enabled.
  • If you set this variable to false, transaction tracking of AAR is disabled.

By default, this value is not set, which means transaction tracking is disabled.

KNJ_AAR_BATCH_FREQ Optional Interval at which AAR data is sent, in seconds Specifies the interval at which the AAR data is batched and sent to the server, in seconds.

The default value is 60, which means the AAR data is batched and sent to the server every minute.

Note: This variable works with KNJ_AAR_BATCH_COUNT to determine when AAR data is batched and sent to the server. When the condition that is set by either of the two variables is met, AAR data is batched and sent. When the requests that the AAR data contains reaches the maximum number, for example 100, at a shorter interval than what is set, the data is still batched and sent immediately.
KNJ_AAR_BATCH_COUNT Optional Maximum number of requests that a batch of AAR data contains Specifies the maximum number of requests that a batch of AAR data can contain before it is sent to the server.

The default value is 100, which means when the number of requests that a batch of AAR data contains reaches 100, this batch of AAR data is sent to the server.

KNJ_LOG_LEVEL Optional Level of information that is printed in the log Controls the level of information that is printed in the log. The following levels are provided:
off
Logs are not printed.
error
Information is only logged on an error condition.
info
Information is logged when the Node.js agent data collector is running normally. The raw monitoring data that is sent to the agent is also logged.
debug
The debug, info, and error information are printed in the log, for example, collected data, data that is sent to server, and server response.
all
All information is printed in the log.

By default, the log level is info, which means the summary information about the data collector actions is printed in the log. Logs are printed to standard output.

SECURITY_OFF Optional
  • true
  • false
Enables or disables collection of user sensitive information, such as cookies, HTTP request context, and database request context.
  • If you set this variable to true, user sensitive information is collected.
  • If you set this variable to false, user sensitive information is not collected. This is the default value.

If you do not specify this variable, the default value of false is used and user sensitive information is not collected.

Example of yaml file

spec:
      containers:
      - name: testapp
        image: mycluster.icp:8500/default/testapp:v1
        imagePullPolicy: Always
        ports:
        - containerPort: 3000
          protocol: TCP
        env:
        - name: KNJ_LOG_LEVEL
          value: "debug"
        - name: KNJ_ENABLE_TT
          value: "true"
        - name: KNJ_ENABLE_DEEPDIVE
          value: "true"