Configure the Node-RED LAM

To use the Node-RED connector for Moogsoft AIOps you will need to install some components.

See Node-RED for UI configuration instructions.

Install Node and Node-RED

  1. Install node.js: see https://nodejs.org/en/download/ for downloads and details. We recommend the LTS version.

  2. Install Node-RED. See https://nodered.org/.

Install the Moogsoft AIOps node

cd ~/.node-red 
npm install node-red-contrib-moog

Install a Generic REST listener

In Moogsoft AIOps, 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 AIOps connection nodes attributes accordingly.

Build your first flow

You now have the basic framework to start building flows and sending messages to Moogsoft AIOps. To test this we will build a basic flow using the Inject input node.

  1. Start Node-RED:

    node-red
  2. Point your browser at the URL provided by the Node-RED start script, the default will be 'Server now running at http://localhost:1880/ '.

  3. Drag the inject node on the left from the input palette onto the workspace.

  4. 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

  5. Click Done.

  6. Connect this message to Moogsoft AIOps:

    1. convert the payload to a Javascript Object

    2. drag the json node from the function palette

    3. connect the output from the Inject node to the input of the json node

    4. drag in the moog node from the output palette

    5. wire the output from the json node to the input of the moog node.

  7. Double click the moog node and enter the URL, User ID and Password provided in the Generic connector screen in Moogsoft AIOps.

  8. 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 AIOps.

Or import this sample flow, replacing yourinstance and yourpassword with the details found in the Moogsoft AIOps 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.

  1. 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.

  2. 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;
  3. Click Done when completed.

  4. Double click the moog node and add credentials as before, then click done.

  5. Publish the flow and check the alerts in Moogsoft AIOps, 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.