The following information is collected and transmitted to SPM (Cloud or On-Premises version):
The module is able to run in cluster mode (master/worker).
Supported Node-Versions: Node >= 0.10, 0.12, 4.x, 5.x, 6.x
npm install spm-agent-nodejs
Get a free account and create a Node.js API token at sematext.com/spm
We use https://www.npmjs.com/package/rc for configuration. This means config parameters can be passed via several config locations command-line args or ENV variables. We recommend to use a file in current directory in INI or JSON format called ".spmagentrc". This file can be generated by providing setting and environment variable and calling a helper script:
export SPM_TOKEN=YOUR-SPM-TOKEN node ./node_modules/spm-agent-nodejs/bin/spmconfig.js
The command above generates following default configuration file (YAML format):
# Directory for buffered metrics dbDir: ./spmdb # Application Token for SPM tokens: spm: YOUR-SPM-TOKEN logger # log file directory default is ./spmlogs dir: ./spmlogs # silent = true means no creation of log files silent: false # log level for output - debug, info, error, defaults to error to be quiet level: error
The only required setting is the SPM Application Token, this could be set via config file ".spmagentrc" or environment variable:
Please note the use of double "_" for nested properties
export SPM_TOKEN=token # default is SaaS at sematext.com, URL needs to be changed for on-prem to the local SPM receiver export SPM_RECEIVER_URL=https://local-spm-server:8084/_bulk export EVENTS_RECEIVER_URL=https://local-event-receiver/ export SPM_DB_DIR=/tmp export SPM_LOG_DIRECTORY=./logs export SPM_LOG_LEVEL=error export SPM_LOG_TO_CONSOLE=true export HTTPS_PROXY=http://my-local-proxy-server
Add this line at the begin of your source code / main script / app.js
var spmAgent =
There is an alternative using latest 4.x and 5.x releases. It supports a command line option "-r" to preload node modules before the actual application is started. In this case the original source code needs no modification:
node -r './spm-agent-nodejs' yourApp.js
Please visit our WIKI for more information
Please check out spm-metrics-js to monitor any custom metric in your application.
Apache 2 - see LICENSE file.