Moogsoft Docs

Moolet Informs

You can configure a Moolet to exchange messages about update information with other Moolets using the Moolet Informs module. For example, after you label some alerts you can configure the module to inform the ticketing Moolet to update the severity of a ticket based on the new label.

To enable this functionality, you add the Moolet Informs module at the start of a Moobot associated with the Moolet you want to send inform messages from.

Before You Begin

Before you get started, ensure you have met the following requirements:

  • You have a Moolet and associated Moobot you want to send inform messages from.

  • You know the Moolets you want to receive the inform messages. These are your "targets".

Configure the Module

To use the Moolet Informs module:

  1. Go to the Moobot associated with the source Moolet from which you want to send Inform messages. Load the module at the top of the file:

    var mooletInforms = MooBot.loadModule('MooletInforms');
  2. Create the Moolet Inform using the create method as follows, passing the target Moolets that receive messages from this source:

    var inform = mooletInforms.create("AlertRulesEngine", "Cookbook");

    Specifying the target Moolets is not required in this step. However, you will need to specify the targets later.

    var inform = mooletInforms.create();
  3. Add values to the inform using one or more of the following:

    • inform.setSubject: Subject of the inform message. You can use this to enable a different workflow within the target Moobot.

    • inform.setPayload: Any CEvent object. See Events for more information.

    • inform.setDetails: Details of any other data you want to send as a JSON object.

  4. If you did not specify the target Moolets previously, specify them now:

    • inform.setTarget: List of Moolets the messages are sent to by the Moolet.

  5. There are two ways to configure how the messages are sent. If you have already set your targets:

    inform.send();

    If you have not set your targets, include them in the method call:

    inform.send("AlertRulesEngine", "Cookbook");
  6. Go to the config file for each target Moolet and add an event handler to listen for the Inform messages:

    events.onEvent("informReceive", constants.eventType("mooletInforms.ExampleMoolet")).listen();
  7. There are two ways for the listening target Moolet to access the data.

    function informReceive(inform) {
        var subject = inform.getSubject();
        var payload = inform.getPayload();
        var details = inform.getDetails();
            logger.warning("Received Moolet Inform. Subject [" + subject + "] Payload [" + payload + "] Details [" + details + "]");
    }

    Alternatively, you can use the value method:

    function informReceive(inform) {
        var subject = inform.value("subject");
        var payload = inform.value("payload");
        var details = inform.value("details");
        logger.warning("Received Moolet Inform. Subject [" + subject + "] Payload [" + payload + "] Details [" + details + "]");
    }
  8. You can configure the Moolet to call a specific method for different subjects in the inform messages. For example you can configure a Remedy Moolet to listen for a specific subject in the inform message and route the event to a function:

    events.onEvent("createNewTicket", constants.eventType("mooletInforms.RemedyMoolet.ticketCreate")).listen();

After you have completed your configuration, inform messages are sent to your target Moolets which will call any methods you have added.

Reference

You can use the following methods in the Moolet Informs module:

create();

Creates the Moolet inform message. You can choose to select one or more Moolet targets to receive the messages or you can leave this empty.

Request Arguments

Name

Type

Required

Description

targets

String

No

A single or comma separated list of Moolet names to target.

Return Parameter

A new Moolet Inform Java object

Example

var inform = mooletInforms.create("MaintenanceWindowManager", "AlertRulesEngine");
setSubject

Set the name of the topic for the Moolets to listen for on the Message Bus.

Request Arguments

Name

Type

Required

Description

Subject

String

Yes

Name of subject the Moolets listen for on the Message Bus.

Return Parameter

None

Example

inform.setSubject("subTopic");
setPayload

Any CEvent object . See Events for more information.

Request Arguments

Name

Type

Required

Description

Payload

CEvent

Yes

Any CEvent object that has been passed into the Moobot from the pipeline, or has been retrieved from MoogDb.

Return Parameter

None

Example

inform.setPayload(event);
setDetails

Details of any other data you want to send in the Moolet inform message.

Request Arguments

Name

Type

Required

Description

setDetails

NativeObject

Yes

A JSON object containing any details you want to send.

Return Parameter

None

Example

inform.setDetails({"signature":"Loss of Signal","description":"Loss of Signal","source":"S-DF_P2_1"});
setTarget

Set the target Moolets you want to receive the Moolet inform messages. Use this method if you did not set the target Moolets with the create method.

Request Arguments

Name

Type

Required

Description

targets

String

Yes

A single or comma separated list of Moolet names to target.

Return Parameter

None

Example

inform.setTarget("AlertRulesEngine", "Cookbook");
send

Sends the Moolet inform messages to your target Moolets.

Request Arguments

Name

Type

Required

Description

targets

String

No

The name or names of Moolets to target this message to.

Return Parameter

None

Example

inform.send("Cookbook");
Example

An example of a Moolet Inform that sends a signature, description and source to the Cookbook Moolet:

var mooletInforms = MooBot.loadModule('MooletInforms');
var inform = mooletInforms.create();
inform.setSubject("subTopic");
inform.setPayload(event);
inform.setDetails({"signature":"Loss of Signal","description":"Loss of Signal","source":"S-DF_P2_1"});
inform.send("Cookbook");
}

An example of how to configure the listener or target Moolet:

events.onEvent("handleEvent", constants.eventType("mooletInforms.EmptyMoolet.event_subject")).listen();
events.onEvent("handleAlert", constants.eventType("mooletInforms.EmptyMoolet.alert_subject")).listen();
events.onEvent("handleSig", constants.eventType("mooletInforms.EmptyMoolet.sig_subject")).listen();