How to Use Node-Red with Logentries for Cloud Based Logging

This is a guest post written by Jason Ruane, the Technical Director at Cirkit.io, and originally appeared on the Cirkit.io blog

Node-Red is an app, which runs on top of NodeJs. Node-Red is usually run on cloud servers, but as more powerful CPUs are placed in IoT devices, it is only a matter of time before it can be supported locally. It already runs on Raspberry Pi and Intel Galileo.

Node-Red enables programmers to build systems much quicker.

A programmer can quickly get up and running by using simple drag-and-drop module functionality. However, it still has all the power of regular NodeJS, meaning the programmer can write regular code behind any of the module blocks, building up fully fledged production capabilities.

Node-Red is very easy to start using; it feels like drawing flowcharts that actually come alive. You don’t just design the system, it actually runs.

You could have any IoT device log straight to the cloud while also having cloud based servers do the same, both running Node-Red and piping to Logentries. For example, I did this with a cloud logging robot arm I built for fun.

Node-Red-with-Logentries1

 

We have been using the Logentries service for years now on a wide variety of devices and platforms. It’s great to have a central location to access and search all the logs from multiple projects in one place. As mentioned, I recently found Node-Red, which is a fantastic visual experience for wiring up Internet of Things devices on the net.

Node-red-with-logentries

More about Node-Red

Node-Red runs on server instances providing the cloud computing for IoT or actually out on the devices themselves for edge-based activity. It is powered by NodeJs and it is possible to create modules or “nodes” to extend its capabilities. We created one such module and posted it on github for you to freely use. You can get started on this for free by using IBM’s Bluemix to get a free instance of Node-Red (or install locally) and a free trial of Logentries.

There is a huge benefit to having all these “things” out there logging to a central location on the cloud, since many of them are inaccessible for the manufacturers or administrators.

Watch the video tutorial below to see the installation process and watch the Node-Red Logentries module in action. Or dive right in and install the module yourself with just: npm install node-red-contrib-logentries

Usage and guidance:

This is NodeJs code which adds functionality to the NodeRed suite. You should have NodeJS and NodeRed installed. Then you can call: npm install node-red-contrib-logentries

details-node-red-guidance

 

Once you have it installed, start Node-Red using the command: node red.js

Then with Node-Red running, drag the new module onto the worksheet:

adding-node-to-sheet

 

Double clicking on the Logentries node allows you to set the configuration so the logs arrive in your account. First, get a Logentries Account and create a log using the following Token TCP type:

create-cloud-based-log-destination

Then, navigate to that log and grab its “token code.” That token is what goes into the configuration of the Node-Red node.

find-token-of-new-log

Now, when your Node-Red flow sends logs to the cloud, they appear in the consolidated log account:

cloud-based-logs-instantly-searchable

You can do lots more, like creating advanced alerts on anomalies or inactivity in your data. You can also create dashboards and graph the values of data within the logs.

Another fun exercise is to see how easy it is to send a log of all the MQTT activity to logs for analyzing:

log-mqtt-activity

We hope you enjoy Node-Red, and please leave a message in the comments below if you have any questions or find this tool helpful.

Read more about the Node-Red wrapper on NPMJS.org.

Posted in Feature, IoT, Node.js

Leave a Reply