Configuring the Node.js agent data collector

You can change the behavior of each Node.js agent data collector by changing its runtime configuration in its configuration file.

Runtime configuration file

The Node.js data collector code is in the following directory:

KNJ_NPM_LIB_LOCATION/node_modules/ibmapm

where KNJ_NPM_LIB_LOCATION is the directory to the lib folder of your npm package global installation directory. The default directory is /usr/local/lib.

There is also a runtime configuration file for each agent data collector in the same folder. The agent data collector reads the configuration file every minute.

Tip: The runtime configuration file is named in the following format:

plugin_application port number_conf.json

When you change the content of the configuration file, the behavior of the associated agent data collector changes. There are two types of information in the configuration file that you can change:

URL filtering rules

You can change URL filtering rules in the runtime configuration file. Regular expressions are used to map the URL path name to a user customized path name. You can map the URL to a customized path name to satisfy the following requirements:
  • Aggregating URLs with similar paths. For example, you have the following URL paths:
    /demo/poll/1
    /demo/poll/2
    /demo/poll/3
    ...
    On the web server, requests for these paths are likely served by a common routine, so you can aggregate the paths to a single URL type by using the filter in the following example.
    "filters":
    [
    	{
    		"pattern": "/demo/poll/.+",
    		"to": "/demo/poll/"
    	}
    
    This filter results in all requests to URL paths like "/demo/poll/xxx" being mapped to a URL path type of "/demo/poll". The response time for all requests to URL paths of this type are then averaged to a single value. Aggregating in this way can help you make more efficient use of available resources.
  • Ignoring URL paths to static files or filtering out certain types of requests. For example, if a web page includes images that generate separate server download requests, you might not be interested in seeing response times for these types of requests.

    To filter out a type of request, set the "to" value to empty as in the format of the following example:

    "filters":
    [
    	{
    		"pattern": "GET /css/.+\\.css$",
    		"to": ""
    	}
    

    This filter causes the requests to get a .css file to be ignored. As a result, you can use the available resources more efficiently on the requests that you need to monitor.

In the configuration file, URL filter rules are provided in a JSON array named filters:
"filters":
[
    {
        "pattern": ".+\\.png$",
        "to": ""
    },
    {
        "pattern": ".+\\.jpg$",
        "to": ""
    },
    {
        "pattern": "GET /js/.+\\.js$",
        "to": ""
    },
    {
        "pattern": "GET /css/.+\\.css$",
        "to": ""
    }
]
Each member in the array is a filtering rule. When an HTTP request is received by the agent data collector, the agent data collector extracts the URL path name from the request and compares it with each "pattern". If the path name does not match a "pattern", the original URL path name is kept and used for measurements.

Agent data collector logging parameter

You can change logging behaviors by modifying the parameter in the config.properties configuration file in the KNJ_NPM_LIB_LOCATION/node_modules/ibmapm/etc directory. The following logging parameter is provided for you to change:
The log level
The entry in the configuration file for log level is KNJ_LOG_LEVEL=info, which means the summary information about the actions is printed in the log. You can set the log level by changing the value of KNJ_LOG_LEVEL. The default value is info and the log is printed to standard output.
The following five log level values are supported:
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
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.