A basic configuration for the plugin in the appropriate global config file: conf.d/node.d.conf, which is also in JSON format. If the module should be enabled by default, add a section for it in the modules dictionary.

A line for the plugin in the appropriate Makefile.am file: node.d/Makefile.am under dist_node_DATA.

A line for the plugin configuration file in conf.d/Makefile.am: under dist_nodeconfig_DATA

Optionally, chart information in web/dashboard_info.js. This generally involves specifying a name and icon for the section, and may include descriptions for the section or individual charts.

Node.js is perfect for asynchronous operations. It is very fast and quite common (actually the whole web is based on it).
Since data collection is not a CPU intensive task, node.js is an ideal solution for it.

node.d.plugin is a netdata plugin that provides an abstraction layer to allow easy and quick development of data
collectors in node.js. It also manages all its data collectors (placed in /usr/libexec/netdata/node.d) using a single
instance of node, thus lowering the memory footprint of data collection.

Of course, there can be independent plugins written in node.js (placed in /usr/libexec/netdata/plugins).
These will have to be developed using the guidelines of External Plugins.

To run node.js plugins you need to have node installed in your system.

In some older systems, the package named node is not node.js. It is a terminal emulation program called ax25-node.
In this case the node.js package may be referred as nodejs. Once you install nodejs, we suggest to link/usr/bin/nodejs to /usr/bin/node, so that typing node in your terminal, opens node.js.
For more information check the Installation guide.

node.d.plugin will run in debug mode (lots of debug info), with an update frequency of 1 second, evaluating only
the collector scripts X (i.e. /usr/libexec/netdata/node.d/X.node.js), Y and Z.
You can define zero or more modules. If none is defined, node.d.plugin will evaluate all modules available.

Keep in mind that if your configs are not in /etc/netdata, you should do the following before running node.d.plugin:

a function to fetch the data from its source. node.d.plugin already can fetch data from web sources,
so you don’t need to do anything about it for http.

a function to process the fetched/manipulate the data fetched. This function will make a number of calls
to create charts and dimensions and pass the collected values to netdata.
This is the only function you need to write for collecting http JSON data.

a configure and an update function, which take care of your module configuration and data refresh
respectively. You can use the supplied ones.

Your module will automatically be able to process any number of servers, with different settings (even different
data collection frequencies). You will write just the work needed for one and node.d.plugin will do the rest.
For each server you are going to fetch data from, you will have to create a service (more later).

To provide a module called mymodule, you have create the file /usr/libexec/netdata/node.d/mymodule.node.js, with this structure:

// the processor is needed only// if you need a custom processor// other than httpnetdata.processors.myprocessor={name:'myprocessor',process:function(service,callback){/* do data collection here */callback(data);}};// this is the mymodule definitionvarmymodule={processResponse:function(service,data){/* send information to the netdata server here */},configure:function(config){vareligible_services=0;if(typeof(config.servers)==='undefined'||config.servers.length===0){/* * create a service using internal defaults; * this is used for auto-detecting the settings * if possible */netdata.service({name:'a name for this service',update_every:this.update_every,module:this,processor:netdata.processors.myprocessor,// any other information your processor needs}).execute(this.processResponse);eligible_services++;}else{/* * create a service for each server in the * configuration file */varlen=config.servers.length;while(len--){varserver=config.servers[len];netdata.service({name:server.name,update_every:server.update_every,module:this,processor:netdata.processors.myprocessor,// any other information your processor needs}).execute(this.processResponse);eligible_services++;}}returneligible_services;},update:function(service,callback){/* * this function is called when each service * created by the configure function, needs to * collect updated values. * * You normally will not need to change it. */service.execute(function(service,data){mymodule.processResponse(service,data);callback();});},};module.exports=mymodule;