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.
plugin_application port number_conf.json
URL filtering rules
- Aggregating URLs with similar paths. For example, you have the following URL
paths:
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./demo/poll/1 /demo/poll/2 /demo/poll/3 ...
This filter results in all requests to URL paths like"filters": [ { "pattern": "/demo/poll/.+", "to": "/demo/poll/" }
"/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.
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
- 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 ofKNJ_LOG_LEVEL
. The default value isinfo
and the log is printed to standard output.