Moogsoft Docs

LAMbot Configuration

LAMbots are JavaScript modules associated with every LAM. The LAMbots control the actions the LAM performs at startup and any necessary processing before forwarding objects to the Message Bus.

You can configure a LAMbot by modifying the functions and modules within its configuration file. The LAMbot files are located at $MOOGSOFT_HOME/bots/lambots.

LAMbot Functions

Each LAMbot includes an onLoad function that runs at startup and a presend function that processes and filters objects before sending them to the Message Bus.

REST-based LAMbotscall modifyResponse after they receive an object and convert it to JSON.

REST Client-based LAMbots call preClientSend before they send a request to a polled server and modifyResponse after a response is received from a polled server.


Every instance of a LAMbot calls the onLoad function at startup. We recommend setting up shared values or lookup tables in the onLoad function. You can use it to initalize internal variables, load external JavaScript modules and set up structures needed for the filter function. For example:

var config = MooBot.loadModule('Config');
var moogUrl;

function onLoad() 
    var servletsConf = config.getConfig('servlets.conf');
        if (servletsConf) 
        moogUrl = servletsConf.webhost;

The onLoad function:

  • Stores the value of the servlets configuration in the config module to a variable "servletsConf".

  • Sets the variable moogURL to the servlets webhost value.


The LAMbot calls the presend function every time it assembles an object to publish on the Message Bus. Moogfarmd processes objects and turns them into alerts and Situations. An example presend function is:

function presend(event)
        if (overflow.LamInstanceName && (overflow.LamInstanceName === "DATA_SOURCE"))
        delete overflow.LamInstanceName;
        event.setCustomInfoValue("nodeSeverity", overflow.Severity);
    event.setCustomInfoValue("nodeMachineType", overflow.MachineType);
    event.setCustomInfoValue("nodeVendor", overflow.Vendor);
    return true;

The presend function:

  • Adds the overflow object as event details.

  • Checks whether LamInstanceName is the default value DATA_SOURCE and if so, removes it from custom info.

  • Saves three overflow fields to custom info.

  • Returns a true response to indicate that the object will be passed to the Message Bus.

You can partition event streams into substreams for differential processing in a distributed environment. You can send a boolean response if the configuration dictates that all objects will or will not be sent to the bus.

Instead of a boolean response, you can configure the function to return a JSON object containing two members: "passed" which is either true or false, and "stream" which defines the substream to send the event. For example:

function presend(event)
        "stream" : "my_stream",
        "passed" : true

You can configure the event inside the presend function. For example you can:

  • Change values

  • Access lookup tables

  • Add or remove key value bindings

  • Access regular expressions

  • Extract tokens

In the LAMbot, the following line instructs the LAM to use the presend function. It calls filterFunction using the global LamBot variable:


The filterFunction function receives a string, which is the name of the function to use for filtering.

You define the presend processing file or stream in individual LAM configuration files. See "Filtering" in Data Parsing for more information.


REST Client-based LAMbots call preClientSend before they send a request to a polled server. The function accepts an object and returns a modified version that is then sent by the Rest Client LAM. An example preClientSend function is:

function preClientSend(outBoundEvent)
    outBoundEvent.set('method', 'Post');
    var header = outBoundEvent.value('header');
    header['Content-Type'] = 'application/json';
    outBoundEvent.set('header', header);
    var body = { 'events': 'all', 'type': { 'id': '12345', 'name': 'incident' } };
    outBoundEvent.set('body', body);
    return true;

The function generates a POST request with body type JSON.

In the LAMbot, the following line instructs the LAM to use the preClientSend function. It calls preClientSendFunction using the global LamBot variable:


You can modify the response sent by a REST-based LAMbot after it receives an object and a REST Client-based LAMbot after it receives a response from a polled server. An example modifyResponse function is:

function modifyResponse(inBoundEventData)
    var response = JSON.parse(inBoundEventData.value('responseData'));
    if (inBoundEventData.value('moog_target_name') == 'target1') {
        response['manager'] = 'primary';
    else {
        response['manager'] = 'secondary';
    inBoundEventData.set('responseData', JSON.stringify(response));
    return true;

The function generates a different response depending on the name of the REST client target called.

In the LAMbot, the following line instructs the LAM to use the modifyResponse function. It calls modifyResponseFunction using the global LamBot variable:

LAMbot Modules

You can load modules into a LAMbot to perform various tasks. The most commonly used modules are:

  • Logger: Moogsoft AIOps components generate log files to report their activity.

  • Constants: Used to share logic, states and flags between LAMbots.

  • Utilities: A JavaScript utility used to escape and convert XML strings and JSON objects.

Define a global object to load a module into a LAMbot. For example:

var logger = LamBot.loadModule("Logger");
var constants = LamBot.loadModule("Constants");
var utilities = LamBot.loadModule("Utilities");