teaser3.png

Send multi-dimensional array to InfluxDB and Nexeed IAS via Node-RED

DraganX
Established Member
Introduction

Node-RED, being a flow-based, low-code development tool for visual programming, offers us the advantage of effortlessly crafting projects with expansive capabilities. Our approach involves extracting raw values from the Data Layer at a high frequency, aggregating them within Node-RED, and transmitting them to InfluxDB for storage and visualization.

Schematic diagramSchematic diagram

Requirements
 
InfluxDB
Step 1: Install and configure Node-Red and InfluxDB

The initial step involves installing the required apps and configuring them. As the primary focus of the article is not on this setup process, the correct configuration can be ensured by referring to the following link: Use ctrlX CORE as a monitoring platform using InfluxDB and Grafana 

Step 2: The Flow

To illustrate the process, we will utilize 10 specific data points: a single PLC counter function and nine consistently present system values. The PLC counter has been set to increment every milisecond.

Within our workflow, we opted for Node-RED Data Layer Subscribe nodes over Data Layer Request nodes due to their demonstrated efficiency and lower impact on the system's CPU. Since the Subscribe node transmits a value solely when a change occurs, we must manually dispatch the same value during periods of inactivity, when no changes are detected. To accomplish this, we employ both a "change" node and an "inject" node set at a 100ms interval. Additionally, all Subscribe nodes are configured to publish at the same 100ms interval.

The Node-RED flowThe Node-RED flow

Following the inject node, the values are held in the "batch" node until 10 values accumulate. They are then transmitted to the first join node, where they are organized into an array. After this initial join, all the individual arrays containing data points are merged within the second "join" node, resulting in a consolidated large array.

The provided image illustrates a segment of the flow featuring all the requisite configurations.

One segment configurationOne segment configuration

The CORE CPU is significantly impacted during these processes, specifically when retrieving values from the Data Layer and transmitting them to InfluxDB. While we have optimized the former using Subscribe nodes, a parallel optimization is now necessary for InfluxDB. Rather than using separate "influxdb out" nodes for each data point, the approach is to consolidate them into a single node. However, before implementing this consolidation, it is essential to include a "function" node to configure the line protocol. This part is explained in Step 2.

In the end, all data flows into InfluxDB over the "influxdb out" node and looks like this:

InfluxDB visualizationInfluxDB visualization

Step 3: The Function

After collecting and combining the data points, we need to modify the output to align with the format accepted by InfluxDB, known as the Line Protocol.
The correct Line Protocol for InfluxDB is exemplified in the following link.

To accommodate the changes, a "function" node is employed, and the output is configured accordingly. An illustrative example can be observed in the picture below.

Code in function nodeCode in function node

Nexeed IAS

The motivation for this project stemmed from the exploration of sending multi-dimensional arrays to a Nexeed IAS server, showcasing the significant possibilities. Utilizing the same process, a different function node was implemented to adapt to the Line Protocol specifications employed by Nexeed IAS.

Sending to NexeedSending to Nexeed

In this demonstration, we have 80 data points with a 100ms sampling rate. Utilizing our approach to minimize the impact on CPU, we successfully transmitted the data to the server with negligible loss. However, it's worth noting that at this point, we were approaching the limits of Node-RED.

80 data points in Node-RED80 data points in Node-RED
One part of the flowOne part of the flow

Following the function node, where the arrays are formatted into the correct line protocol, the data is transmitted to Nexeed, resulting in the following representation.

NEXEED visualizationNEXEED visualization

To give it a try, please copy the content from the attachments and paste it into Node-RED.

DraganX
DraganX
Hello, I'm Dragan from DCEM/Application, Austria. (Bosch Rexroth)
Must Read
Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist