NodeJS

InsightOps supports logging using node.js.

basic

Setup

Log in to InsightOps and create a new log by clicking the Add Data button in the Data Collection page. Now click the Quick Add button from the list of options. Give your log a name of your choice, select Token TCP and finally click the Register new log button. A token will be displayed in green. Please record it as we will use it later to configure the library.

basic

Install Logentries library

Run the following command to install node.js library:

1
npm install r7insight_node

Configure your code

javascript
1
var Logger = require('r7insight_node');
2
3
var logger = new Logger({ token: 'logToken' , region: 'myRegion'});
4
5
logger.warning('The kittens have become alarmingly adorable.')

The Log Token parameter needs to be replaced with the token for the log we created earlier. We then need to enter in the Region which our InsightOps account is based e.g us, eu, apac.

There are many other options available when instantiating the Logger, which you can read about on the project page.

Insert Logging Code

The module provides you with a set of logging methods that correspond to the standard syslog log levels. These are, in order of increasing severity: debug, info, notice, warning, err,`` crit, alert, emerg```.

javascript
1
// level specific methods like 'info', 'debug', etc.
2
logger.info("I'm a Lumberjack and I'm OK")
3
4
// generic log method, also accepts JSON entries
5
logger.log("debug", {sleep:"all night", work:"all day"})