Skip to content
Branch: master
Clone or download
Type Name Latest commit message Commit time
Failed to load latest commit information.
bin spm-support@ ==> support@ Jun 19, 2017
example style: standard Mar 8, 2017
lib update node packages Dec 28, 2018
test fix travis test Oct 25, 2018
.gitignore added .gitignore Apr 4, 2015
.travis.yml run travis test for LTS versions - until node 12 gc-stats build is fixed Apr 29, 2019
LICENSE Tweaked a few old links Apr 29, 2019
package-lock.json update dependencies Apr 26, 2019
package.json Release 2.0.3 Apr 26, 2019


build status


This is the Node.js monitoring agent for Sematext Cloud.

The following information is collected and transmitted to SPM (Cloud or On-Premises version):

  • OS Metrics (CPU / Mem)
  • Process Memory
  • EventLoop stats
  • Garbage Collector stats
  • Web server stats (requests, error rate, response times etc.) Working for all web servers frameworks that use Node.js http/https module including
    • "connect" based frameworks
    • Express.js,
    • Sails.js
    • Hapi.js
    • Restify
    • and others ...

The module is able to run in cluster mode (master/worker).


Supported Node-Versions: Node >= 6.x.

Please check our blog for more information or contact us at


    npm install spm-agent-nodejs

Get a free account and create a Node.js API token at


We use 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:

    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
      spm: YOUR-SPM-TOKEN

      # 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:

export spmagent_tokens__spm=YOUR-SPM-APP-TOKEN

Please note the use of double "_" for nested properties

Configuration via Environment Variables

export SPM_TOKEN=token
# default is SaaS at, 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

Changing API endpoints for Sematext Cloud EU



Method 1: Preloading spm-agent-nodejs - no source code modifications requred

The command line option "-r" preloads 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

Method 2: Add spm-agent-nodejs to your source code

Add this line at the begin of your source code / main script / app.js

# add spm-agent-nodejs to your project
npm i spm-agent-nodejs --save
    var spmAgent = require ('spm-agent-nodejs')



Please visit our documentation for more information.

Other monitoring packages

Please check out spm-metrics-js to monitor any custom metric in your application.

Sematext Docker Agent (see also: and


Apache 2 - see LICENSE file.

You can’t perform that action at this time.