Configure the Node-RED LAM
To use the Node-RED connector for Moogsoft Onprem you will need to install some components.
See Node-RED for UI configuration instructions.
Install Node and Node-RED
Install node.js: see https://nodejs.org/en/download/ for downloads and details. We recommend the LTS version.
Install Node-RED. See https://nodered.org/.
Install the Moogsoft Onprem node
cd ~/.node-red npm install node-red-contrib-moog
Install a Generic REST listener
In Moogsoft Onprem, log in as an admin, select System Administration from the menu then select monitoring from under the Integrations heading. Install a Generic monitoring component by clicking on the +Add Monitoring Integration option and selecting the Generic tile. We will use the name Generic1 for this tutorial so if you choose a new name please make a note to change the Moogsoft Onprem connection nodes attributes accordingly.
Build your first flow
You now have the basic framework to start building flows and sending messages to Moogsoft Onprem. To test this we will build a basic flow using the Inject input node.
Start Node-RED:
node-red
Point your browser at the URL provided by the Node-RED start script, the default will be 'Server now running at http://localhost:1880/ '.
Drag the inject node on the left from the input palette onto the workspace.
Double click this node and configure the properties as follows:
Payload: {}JSON: {"description":"Node-red Heartbeat","source":"myHost","agent_location":"Node-RED","severity":"0"}
Topic: Heartbeat
Repeat: Interval, 15 Seconds and check the Inject once at start option
Click Done.
Connect this message to Moogsoft Onprem:
convert the payload to a Javascript Object
drag the json node from the function palette
connect the output from the Inject node to the input of the json node
drag in the moog node from the output palette
wire the output from the json node to the input of the moog node.
Double click the moog node and enter the URL, User ID and Password provided in the Generic connector screen in Moogsoft Onprem.
Click on the Deploy button in the top right of the Node-RED screen to save your flow to the server. If all is correct you should see the moog node is now 'connected' and a 'heartbeat' alert should be seen in your all alerts list in Moogsoft Onprem.
Or import this sample flow, replacing yourinstance and yourpassword with the details found in the Moogsoft Onprem connector configuration screen.
[{"id":"561eb847.e6bd48","type":"tab","label":"Flow 1"},{"id":"804d8f6a.50956","type":"moog","z":"561eb847.e6bd48","name":"","url":"https://yourinstance.moogsoft.com/events/Generic1","user":"Generic","pass":"yourpassword","x":519,"y":105,"wires":[]},{"id":"69318047.adc82","type":"inject","z":"561eb847.e6bd48","name":"Heartbeat","topic":"heartbeat","payload":"{\"description\":\"Heartbeat\",\"agent_location\":\"mylaptop\",\"agent\":\"Node-red Heartbeat\",\"severity\":0}","payloadType":"json","repeat":"300","crontab":"","once":true,"x":141,"y":105,"wires":[["543ed6ad.ac51d8"]]},{"id":"543ed6ad.ac51d8","type":"json","z":"561eb847.e6bd48","name":"","x":337,"y":105,"wires":[["804d8f6a.50956"]]}]
Build a Twitter Flow
To build the Twitter feed, you will need a Twitter account.
Drag the Twitter node from social, the sentiment node from analytics and a function node, optionally add a debug output node and wire them all together with the moog node.
Double click the Twitter node and add your credentials, clicking done when completed. Then double click the function node, give it a name and then enter this code:
var score; msg.moog= {}; msg.moog.class = 'Twitter'; msg.moog.type = msg.topic; if (msg.location && msg.location.place) msg.moog.location = msg.location.place; msg.moog.description = msg.payload; msg.moog.source = msg.tweet.user.name; msg.moog.external_id = msg.tweet.id_str; if (msg.sentiment && msg.sentiment.score) { score = Math.round(Math.abs(msg.sentiment.score - 5) / 2); if (score < 0) score = 0; if (score > 5) score = 5; msg.moog.severity = score; } return msg;
Click Done when completed.
Double click the moog node and add credentials as before, then click done.
Publish the flow and check the alerts in Moogsoft Onprem, you should see tweet events in your alert list.
Congratulations you now have a Twitter feed!
Check the Node-RED LAM Status
You can use a GET request to check the status of the Node-RED LAM. See "Check the LAM Status" in Configure the REST LAM for further information and examples.