Moogsoft Docs

MoogDb V2

You can query and manipulate a variety of entities in the Moogsoft AIOps database using the MoogDb V2 Moobot module.

The module uses various methods to retrieve information from MoogDb and update components of Moogsoft AIOps including alerts, Situations, users and teams.

All MoogDb V2 methods that update the database also publish information about the appropriate updated entities on the Configure the Message Bus, so any updated information automatically appears in Moogsoft AIOps when the relevant method is called.

Load MoogDb V2

You can load the MoogDb V2 module into any standard MooBot by defining a new global object called moogdb at the top of the JavaScript file:

var moogdb = MooBot.loadModule('MoogDb.V2');
Methods

All available MoogDb V2 methods are described in the sections below:

addAlertToSituation

Adds a specified Alert to a Situation.

Request Arguments

Name

Type

Description

alertId

Number

The Alert ID

situationId

Number

The Situation ID

Return Parameter

Type

Description

Boolean

Indicates if the operation was successful: true = success, false = fail

addCorrelationInfo

Adds correlation information (external service name and external entity ID) to a Situation.

Request Arguments

Name

Type

Description

situationId

Number

The Situation ID

service 

String

The name of the external service, such as ServiceNow

externalId

String

The identifier that the entity has in the external service, which corresponds to the Situation

Return Parameter

Type

Description

Boolean

Indicates if the operation was successful: true = success, false = fail

addSigCorrelationInfo

Adds correlation information (external service name and external entity ID) to a Situation. This is the recommended method for adding correlation information to a Situation, the addCorrelationInfo method has been retained for backwards compatibility.

Request Arguments

Name

Type

Description

situationId

Number

The Situation ID

service 

String

The name of the external service, such as ServiceNow

externalId

String

The identifier that the entity has in the external service, which corresponds to the Situation

Return Parameter

Type

Description

Boolean

Indicates if the operation was successful: true = success, false = fail

addProcess

Adds a new process to the database.

Processes are external business entities related to business activities that are affected by the incidents that Moogsoft AIOps captures in Situations.

Request Arguments

Name

Type

Description

process

String

The process name

description

String

The process description.

Return Parameter

Type

Description

Boolean

Indicates if the operation was successful: true = success, false = fail

addService()

Adds a new external service to the database.

An external service is a business entity monitored by Moogsoft AIOps via Event streams.

Request Arguments

Name

Type

Description

service

String

The name of the external service being added

description

String

The service description

Return Parameter

Type

Description

Boolean

Indicates if the operation was successful: true = success, false = fail

addThreadEntry

A POST request that adds a new entry to an existing thread in a Situation. Optionally, you can specify the new entry as being a resolving step.

Threads are comments or 'story activity' on Situations.

This endpoint returns the entry ID of the newly created thread entry.

Request Arguments

Name

Type

Required

Description

entry

String

Yes

Description of the new entry you want to add to the existing thread. For example, "And another thing...".

thread_name

String

Yes

Name of the existing thread.

user_id

Nunber

Yes

A valid user ID.

sitn_id

Number

Yes

Situation ID.

resolving_step

Boolean

No

Whether or not the thread entry you are adding is a resolving step. Defaults to false if not specified,

Return Parameter

Successful requests return the following:

Type

Description

Number

ID of the new thread entry.

Examples

Request to add an entry "New Entry" to thread "Support" in Situation 158 using user ID 47. The resolving step parameter defaults to false.

var newThreadEntryID = moogdb.addThreadEntry(“New Entry”, “Support”, 47, 158);

Request to add an entry "New Entry" to thread "Support" in Situation 58 using user ID 47. This thread entry is a resolving step:

var newThreadEntryID = moogdb.addThreadEntry(“New Entry”, “Support”, 47, 158, true)

Returns the new thread entry ID:

345
assignAlert

Assigns an Alert to a valid user, identified by their user ID.

Request Arguments

Name

Type

Description

alertId

Number

The Alert ID

userId

Number

A valid user ID

username

String

A valid user name

Return Parameter

Type

Description

Boolean

Indicates if the operation was successful: true = success, false = fail

assignAndAcknowledgeAlert

Assigns an Alert to a valid user, identified by their user ID, and acknowledge the alert.

Request Arguments

Name

Type

Description

alertId

Number

The Alert ID

userId

Number

A valid user ID

username

String

A valid user name

Return Parameter

Type

Description

Boolean

Indicates if the operation was successful: true = success, false = fail

assignAndAcknowledgeSituation

Assigns a Situation to a valid user, identified by their user ID, and acknowledge the situation.

Request Arguments

Name

Type

Description

situationId

Number

The Situation ID

userId

Integer

A valid user ID

username

String

A valid user name

Return Parameter

Type

Description

Boolean

Indicates if the operation was successful: true = success, false = fail

assignModerator

Assigns a Situation to a valid user, identified by their user ID.

Request Arguments

Name

Type

Description

situationId

Number

The Situation ID

moderatorId

Number

A valid user ID

username

String

A valid user name

Return Parameter

Type

Description

Boolean

Indicates if the operation was successful: true = success, false = fail

assignTeamsToSituation

Assigns one or more teams to a Situation. Once successfully run, Moogsoft AIOps marks the Situation as overridden and the Teams Manager Moolet can no longer modify its team assignment. See Teams Manager Moolet for more information.

The method replaces any teams previously assigned to the Situation. You can also use it to unassign all teams from a Situation.

Request Arguments

Include either team_ids or team_names.

Name

Type

Description

sitn_id

Number

The Situation ID.

team_ids

JSON list

A list of team IDs to assign to the Situation. Specify an empty list to unassign all teams from the Situation.

team_names

JSON list

A list of team names to assign to the Situation. Specify an empty list to unassign all teams from the Situation.

Return Parameter

Type

Description

Native object

A Javascript object containing a list of the team names or team IDs assigned to the Situation, depending on the input.

Input Example 1:

var assignTeamIDs = moogdb.assignTeamsToSituation(1, { "team_ids" : [1, 2] } )

Return:

{ "team_ids" : [1, 2] }

Input Example 2:

var assignTeamNames = moogdb.assignTeamsToSituation(2, { "team_names" : [ "Team1", "Team2" ] } )

Return:

{ "team_names" : [ "Team1", "Team2" ] }

Unassign Example:

var unassignTeamIDs = moogdb.assignTeamsToSituation(1, { "team_ids" : [] } )

Return:

{ "team_ids" : [] }
closeAlert

Closes one or more alerts.

Request Argument

Name

Type

Description

alertId

Number

A single alert ID

alertIds

List

A list of alert IDs

thread_entry_comment

String

Optional comment

Return Parameter

Type

Description

Boolean

Indicates if the operation was successful: true = success, false = fail

Example Input

var success = moogdb.closeAlert([78,234,737], "Closing as agreed during team discussion 1/1/2018");
closeSituation

Closes a Situation.

Request Arguments

Name

Type

Description

situationId

Number

The Situation ID

closeAlerts

Constant

Determines how the Alerts in the Situation are treated:

CLOSE_NO_ALERT - No Alerts are closed

CLOSE_ALL_ALERTS - All Alerts are closed

CLOSE_UNUSED_ALERTS - Only the Alerts unique to this Situation (i.e. otherwise unused) are closed

To access these constants from a MooBot, precede them with the module name, for example:

moogdb.CLOSE_NO_ALERT

Return Parameter

Type

Description

Boolean

Indicates if the operation was successful: true = success, false = fail

createAlert

Creates or updates an Alert in the database. Optionally updates custom info for de-duplicated Alerts.

Request Arguments

Name

Type

Description

alert

Native object

A Javascript object containing Alert attributes, such as type, severity, etc

event

CEvent

A CEvent object representing the Alert, containing Alert attributes, such as type, severity, etc

mergeCustomInfo

Boolean

Set this to 'true' to merge the custom_info data in this Alert with the info held in the database

Optional

Return Parameter

Type

Description

CEvent

A CEvent object containing the latest version of the Alert

createMaintenanceWindow

Creates a maintenance window that filters alerts, by passing an object containing the information.

Request Arguments

Name

Type

Description

maintenanceWindowObj

Object

A map containing the following information.

name

String

Mandatory - The name of the maintenance window.

description

String

Mandatory - The description of the maintenance window.

filter

String

Mandatory - The filter to apply to the new alerts created.

start_date_time

Number

(Epoch)

Mandatory - The time in epoch where the maintenance window will start, up to a maximum of 5 years in the future.

duration

Number

(seconds)

Mandatory - The duration in seconds where the maintenance window is running, must be greater than zero.

forward_alerts

boolean

Mandatory - Whether the alert will be forwarded to situation or not.

recurring_period

Number

Optional - Whether or not this is a recurring maintenance window. Set this to:

  • 1 for a recurring maintenance window.

  • 0 for a one-time maintenance window.

If you change this from 0 to 1, you must specify recurring_period_units.

recurring_period_units

Number

Specifies the recurring period of the maintenance window, in days, weeks or months. If you set recurring_period to 0, you must set recurring_period_units to 0. Valid values are:

  • 0 = a one-time maintenance window

  • 2 = daily

  • 3 = weekly

  • 4 = monthly

Input example :

{
        "name": "Mike",
        "description": "A description",
        "filter": "{'column': 'source', 'op': 0, 'value': '\'Nile\'', 'type': 'LEAF'}",
        "start_date_time": 1497971059,
        "duration": 360000,
        "forward_alerts": true,
        "recurring_period": 1,
        "recurring_period_units": 2
}

Return Parameter

Type

Description

Long

The window ID created, or null if an error occurred.

createSituation

Creates a new Situation, containing no Alerts.

Situation settings, such as severity are defined in the following arguments:

Request Arguments

Name

Type

Description

moderator

String

A valid user name

label

String

The new Situation description

Return Parameter

Type

Description

CEvent

The newly created Situation wrapped in a CEvent object

createTeam

Create a new team, by passing an object containing team information.

Request Arguments

Name

Type

Description

teamObj

Object

A map containing the following parameters

name

String

Mandatory - the new team (unique) name

alert_filter

String

Optional - The team alerts filter. Either a SQL like filter or an JSON representation of the filter

services

JSON list

Optional - List of the team services names or IDs

sig_filter

String

Optional - The situation filters. Either a SQL like filter or an JSON representation of the filter

landing_page

String

Optional - The team default landing page

active

Boolean

Optional - False if the team is inactive, true if the team is active. Default to true

description

String

Optional - The team description

users

List of numbers or strings

Optional - The team users (either IDs or usernames)

Input example :

{
        "name": "myTeam",
        "alert_filter": "{ \"column\": \"count\", \"op\": 1, \"value\": 1, \"type\": \"LEAF\" }",
        "sig_filter": "{ \"column\": \"severity\", \"op\": 1, \"value\": 5, \"type\": \"LEAF\" }",
        "active": true,
        "services": [1, 2, 4],
        "users": ["user1", "user4"],
        "description": "myDescription",
        "landing_page": ""
}

Return Parameter

Type

Description

Integer

The team id created, or null if an error occurred.

createThread

Creates a new thread for a Situation.

Threads are comments or 'story activity' on Situations.

Request Arguments

Name

Type

Description

situationId

Number

The Situation ID

thread

String

The name of the new thread

Return Parameter

Type

Description

Boolean

Indicates if the operation was successful: true = success, false = fail

createThreadEntry

Note

This method has been superseded. Use addThreadEntry instead. All new functionality will be delivered in addThreadEntry.

Creates an entry on the specified thread. This method returns a Boolean indicating whether or not the thread entry was created successfully.

Request Arguments

Name

Type

Description

entry

String

The entry as a text string

thread

String

The name of the thread

userId

Number

A valid user ID

situationId

Number

The Situation ID

Return Parameter

Type

Description

Boolean

Indicates if the operation was successful: true = success, false = fail

createUser

Create a user, by passing an object containing user properties

Request Arguments

Name

Type

Description

userObj

Object

A map containing the following user information

username

String

Mandatory - the new user (unique) login username

password

String

The new user password (only valid for DB realm)

active

Boolean

true if the user active, false if the user inactive, default to true

email

String

The user email address

fullname

String

The user full name

roles

JSON list

Mandatory - List of user roles. That list should contain either the list the role IDs or the role names. E.g "roles":["Super User"],

primary_group

String or Number

The user primary group name or primary group id

department

String or number

The user department id or name

joined

Number

The time the user joined (in Unix time)

timezone

String

The user timezone

contact_num

String

The user phone number

session_expiry

Number

The number of minutes after which the user session will expire. Default to system default

competencies

JSON list

A list with the user competencies. Each competency should have have name or cid and ranking. That is, something like:

[{"name":"SunOS", "ranking": 40},{"name":"SAP", "ranking": 50},{"name":"EMC", "ranking": 60}]

teams

JSON list of numbers or strings

List of the user teams. The list should contains either the list of the teams ID or the teams name

Example

Input:

{
        "username": "user1",
        "fullname": "firstName surName",
        "competencies": [{
                        "name": "SunOS",
                        "ranking": 40
                },
                {
                        "name": "SAP",
                        "ranking": 50
                },
                {
                        "name": "EMC",
                        "ranking": 60
                }
        ],
        "roles": ["Super User"],
        "department": 3,
        "active": true,
        "email": "user@email.com",
        "timezone": "a timezone",
        "teams": [1, 2, 4],
        "joined": 12345678,
        "contact_num": "0965412345"
}

Return Parameter

Type

Description

Integer

The user id created, or null if an error occured

createWorkflow

Create a new Workflow at the end of the Moolet sequence. To move it, use reorderWorkflow().

Request Arguments

Name

Type

Description

moolet_name

String

workflow_name

String

description

String

Workflow description.

entry_filter

Filter in JSON or SQL format

The entry filter of the Workflow. Missing, null, or empty means "accept all."

sweep_up_filter

Filter in JSON or SQL format

Check the database for all objects that match the filter criteria and pass them to all workflow actions as a list parameter. The sweep-up filter expedites entry of related objects into the workflow.

For example if you receive a link-up alert, you can set a filter to retrieve all related link-down alerts from the database and have the sweep up filter close them.

A missing, null, or empty argument implies no sweep-up filter.

first_match_only

Boolean

If True, perform workflow operations once only on each object.

operations

JSON Array

Required

A list of operations, each has:

  • Type - (ENUM/String, Required) the type of the operation. Either action, decision, delay. Depending on the type, we’ll read other fields in the JSON

  • Operation_name - (String, Required for action/decision type) Operation name.

  • function_name - (String, Required for action/decision type) Function name.

  • function_args - (JS Object , action/decision types, only optional) Function arguments.

  • Duration - (Integer, Required for delay type) The number of seconds before the message goes to the next operation/Workflow/moolet.

  • Reset - (Boolean, Required for delay type)Reset the timer on each occurrence?

Example

var id = moogdb.createWorkflow(
{
    "moolet_name": "Alerts Workflows",
    "workflow_name": "ChangeInfoWorkflow",
    "description": "Changingthealertinformation",
    "entry_filter": {
            "column": "severity",
            "op": 5,
            "value": 3,
            "type": "LEAF"
    },
    "sweep_up_filter": {
            "column": "description",
            "op": 4,
            "value": "description",
            "type": "LEAF"
    },
    "first_match_only": false,
    "operations": [{
                    "type": "action",
                    "function_name": "functionA",
                    "function_args": {
                            "admin": 2
                    },
                    "operation_name": "do something"
            },
            {
                    "type": "delay",
                    "delay": 30,
            "reset": false
            }
    ]
});
deAssignAlert

Deassigns an alert. Removes the user assigned to the alert and leaves it unassigned.

Request Argument

Name

Type

Description

alertId

Number

The alert ID

Return Parameter

Type

Description

Boolean

Indicates if the operation was successful: true = success, false = fail

deleteMaintenanceWindow

Delete a single maintenance window.

Request Argument

Name

Type

Description

maintenanceWindowId

Number

The maintenance window ID

Return Parameter

Type

Description

Boolean

Indicates if the operation was successful: true = success, false = fail

Examples

Request to delete maintenance window 456:

var success = moogdb.deleteMaintenanceWindow(456)

Successful return:

true
deleteMaintenanceWindows

Delete maintenance windows that match the specified filter. The filter can be JSON or SQL (advanced). See Filter Search Data for further information on creating filters in Moogsoft AIOps.

Request Argument

Name

Type

Description

filter

String

Filter to match maintenance windows that you want to delete. For example, Description matches "maint_window_12".

limit

Number

Maximum number of windows to fetch. Defaults to 100.

Return Parameter

Type

Description

Boolean

Indicates if the operation was successful: true = success, false = fail

Examples

Request to delete maintenance windows that match a filter:

var success = deleteMaintenanceWindows(filter, limit);

JSON filter where the description is "host375":

{ "column": "description", "op": 10, "value": "host375", "type": "LEAF" }

Advanced SQL filter where the description is "host375":

Description MATCHES "host375"

Successful return:

true
deleteWorkflow()

Deletes a Workflow moolet.

Request Arguments

Name

Type

Description

id

Integer

Required -- ID of the workflow to delete.

Response Parameter

Type

Parameter

Boolean

True if the operation succeeded.

getActiveSituationIds

Returns the total number of active Situations, and a list of their Situation IDs. Active Situations are those that are not Closed, Resolved or Dormant.

Request Arguments

None. The above method returns data on all active Situations.

Return Parameter

Type

Description

Native object

A Javascript object containing the total and the Situation IDs

Example

Return:

{
     "total_situations":10,
     "sitn_ids":[4, 5, 6, 12, 14, 15, 16, 17, 18, 19]
}
getAlert

Fetches a specified alert from the database.

Request Argument

Name

Type

Description

alertId

Number

The alert ID

Return Parameter

Type

Description

CEvent

A CEvent object containing the alert attributes, such as type, severity, etc.

getAlertActions

Retrieves the actions for one or more specified alerts or for a specified time period.

Request Arguments

Name

Type

Required

Description

alert_ids

JSON list

No

List of alert IDs.

start

Number

Yes

Starting row from which data should be included.

limit

Number

Yes

Maximum number of actions you want to retrieve.

actions

JSON list

No

List of action codes. If no action codes are specified, all action codes are returned. See Alert Action Codes for a list of action codes and their descriptions. Only action codes 8 (Alert Resolved) and 9 (Alert Closed) are valid.

from

Number

No

Start time (in Unix epoch time) of the period you want to retrieve alert actions for.

to

Number

No

End time (in Unix epoch time) of the period you want to retrieve alert actions for.

Return Parameters

Type

Description

Native object

A JSON object containing the alert action information.

Examples

Request:

var actions = moogdb.getAlertActions(request);

Example request object to return the first 100 actions for alert IDs 1 and 2 for action codes 9 and 10:

{
  “alert_ids” : [1, 2],
  “start”: 0 ,
  “limit” : 100,
  “actions” : [8, 9]
}

Example request object to return the first 100 actions for alert IDs 1 and 2 for action codes 9 and 10 between the Unix epoch times 1553861746 and 1553872546:

{
           "alert_ids" : [1, 2],
           "limit" : 100,
           "actions" : [8, 9],
           "from" : 1553861746,
           "to" : 1553872546 
}

Successful return:

[{
    "uid": 49,
    "action_code": 8,
    "description": "Alert Resolved",
    "details": {},
    "alert_id": 1,
    "timed_at": 1557504393
    }, {
    "uid": 49,
    "action_code": 9,
    "description": "Alert Closed",
    "details": {},
    "alert_id": 1,
    "timed_at": 1557504912
    }
}]
getAlertCustomInfo

Retrieves any custom information from a specific alert.

Request Arguments

Name

Type

Description

alertId

Number

ID of the alert you want to retrieve custom info data from.

key

String

Specify the key if you are interested in a specific value. Otherwise the method returns all custom_info information.

Return Parameter

Type

Description

Number, List, String or Object

A map of name-value pairs containing the new custom_info information.

getAlertIds

Retrieves all alert IDs matching the query.

Request Argument

Name

Type

Description

query

JSON Object

A JSON object containing the alert filter information.

limit

Number

The maximum number of alert ids to return.

Return Parameter

Type

Description

NativeObject

A Javascript object containing the total number of alerts and their alert IDs.

Example

Return:

{
     "total_alerts":10,
     "alert_ids":[4, 5, 6, 12, 14, 15, 16, 17, 18, 19]
}
getSigCorrelationInfo

Retrieves all correlation information related to a specified Situation.

Request Arguments

Name

Type

Description

sitn_id

Number

The Situation ID.

Return Parameter

Type

Description

Object

A Javascript object containing a list of maps of correlation info.

getSigCustomInfo

Retrieves all custom information related to a specified Situation.

Request Arguments

Name

Type

Description

sigId

Number

The Situation ID.

key

String

Node path for specific value to return.

Return Parameter

Type

Description

Number, object, list or string

Depends on the key but can either be a number, object, list or string containing a list of maps of custom info.

getMaintenanceWindows

Get all maintenance windows based on the window id and how many should be fetched.

Request Argument

Name

Type

Description

start

Number

The start point for where to fetch windows from (ie, 0 to start at the first, 10 to start at the 11th)

limit

Number

The number of windows to fetch

Return Parameter

Type

Description

NativeObject

A Javascript object with a nested array.

Example

Return:

{
  "windows": [
    {
      "filter": "{\"op\":6,\"column\":\"severity\",\"type\":\"LEAF\",\"value\":[2]}",
      "duration": 3600,
      "recurring_period": 1,
      "del_flag": false,
      "forward_alerts": false,
      "last_updated": 1491917013,
      "name": "window1",
      "updated_by": 3,
      "description": "dfgvhbjk",
      "id": 1,
      "recurring_period_units": 2,
      "start_date_time": 1491916979
    }
  ]
}
findMaintenanceWindows

Find maintenance windows based on a filter and how many should be fetched.

Request Argument

Name

Type

Description

filter

String

The filter to find windows by. Something like: description matches 'dfgvhbjk'.

limit

Number

The maximal number of windows to fetch. default to 100.

Return Parameter

Type

Description

PublicObject

A Javascript object containing the windows

Example

Return:

{
  "windows": [
    {
      "filter": "{\"op\":6,\"column\":\"severity\",\"type\":\"LEAF\",\"value\":[2]}",
      "duration": 3600,
      "recurring_period": 1,
      "del_flag": false,
      "forward_alerts": false,
      "last_updated": 1491917013,
      "name": "window1",
      "updated_by": 3,
      "description": "dfgvhbjk",
      "id": 1,
      "recurring_period_units": 2,
      "start_date_time": 1491916979
    }
  ]
}
getQueueName

Fetches the queue name from the database, for the given queue ID.

Request Argument

Name

Type

Description

queueId

Number

The queue ID

Return Parameter

Type

Description

String

Queue name

getPrcLabels

Returns probable root cause (PRC) information for all alerts or specified alerts within a specified Situation.

Request Arguments

Name

Type

Description

situationId

Number

The Situation ID

alert_ids

JSON list

A list of the alert IDs (Optional)

Return Parameter

Type

Description

Native object

A Javascript object containing the probable root cause information for the alerts in the specified Situation

Example

Input:

var alertIds = [1,2,3,4];
var prcLabels = moogdb.getPrcLabels(1, alertIds);

Return:

{ 
     "non_causal":
       [2,3],
     "unlabelled":
       [4],
     "causal":
       [1]
}
getProcesses

Fetches a list of processes from the database.

Request Argument

Name

Type

Description

limit

Integer

The maximum number of processes to retreive. 1000 is the default.

Return Parameter

Type

Description

Native object

A list of string hashmaps describing the requested processes, or null value if there is an error.

getResolvingThreadEntries

Returns thread entries that have been marked as resolving steps for the specified Situation. Threads are comments or 'story activity' on Situations.

You can select specific thread entries to return using start and limit values. If not, the first 100 entries will be returned. The entries returned are ordered by most recent entries first.

Request Arguments

Name

Type

Required

Description

situationId

Number

Yes

Situation ID.

thread

String

Yes

Name of the thread.

start

Number

No

Number of the first thread entry to return.

limit

Number

No

Maximum number of thread entries to return.

Return Parameter

Type

Description

Native object

A Javascript object containing details of the selected thread entries.

Examples

Request to return the first 100 thread entries that are resolving steps for Situation 58:

var resolvingEntries = moogdb.getResolvingThreadEntries(58);

Request to return the first 10 thread entries that are resolving steps for Situation 58:

var resolvingEntries = moogdb.getResolvingThreadEntries(58, 0, 10);

Return:

{ 
  "entries": [
              {
                  "uid": 3,
                  "entry": "This one is important. Another comment",
                  "agrees": [],
                  "total_comments": 0,
                  "thread_id": "Support",
                  "mmid": -1,
                  "sig_id": 1,
                  "entry_id": 2,
                  "timed_at": 1423226829,
                  "disagrees": [],
                  "commenters": []
              },
              {
                  "uid": 3,
                  "entry": "No comment. A comment",
                  "agrees": [],
                  "total_comments": 0,
                  "thread_id": "Support",
                  "mmid": -1,
                  "sig_id": 1,
                  "entry_id": 1,
                  "timed_at": 1423226807,
                  "disagrees": [3],
                  "commenters": []
              }
             ],
  "total_entries": 2
}
getServices

Fetches a list of services from the database.

Request Argument

Name

Type

Description

limit

Integer

The maximum number of services to retrieve. 1000 is the default.

Return Parameter

Type

Description

Native object

A list of string hashmaps describing the requested services, or null value if there is an error.

getSituation

Fetches a specified Situation from the database.

Request Argument

Name

Type

Description

situationId

Number

The Situation ID

Return Parameter

Type

Description

Object

A JavaScript object representing the Situation.

getSituationActions

Returns activity for specified Situations. Created by passing an object with the information requested. You can use the from and to arguments to specify a period that you want to retrieve Situation actions for. If you do not specify these, all actions are returned.

Request Arguments

Name

Type

Description

sitn_ids

JSON list

List of Situation IDs.

start

Number

Starting row from which data should be included.

limit

Number

Maximum number of actions you want to return.

actions

JSON list

List of action codes of actions you want to include in the return. If no action codes are specified, all action codes are returned. See Situation Action Codes for a list of action codes and their descriptions.

from

Number

Start time (in Unix epoch time) of the period you want to retrieve Situation actions for.

to

Number

End time (in Unix epoch time) of the period you want to retrieve Situation actions for.

Return Parameter

Type

Description

Native object

A Javascript object containing the activity for specified situations

Example

Input:

var actions = moogdb.getSituationActions(request);

Example request object to return the first 100 actions for Situation IDs 1, 2, and 3 for action codes 1 (Situation Created) and 14 (Added Alerts To Situation):

{ 
     "sitn_ids" : [1, 2, 3],
     "start" : 0,
         "limit" : 100,
         "actions" : [1, 14] 
}

Successful return:

[{
    "uid": 2,
    "action_code": 1,
    "description": "Situation Created",
    "details": {},
    "type": "event",
    "sig_id": 1,
    "timed_at": 1507039842
    }, {
    "uid": 2,
    "action_code": 14,
    "description": "Added Alerts To Situation",
    "details": {}
    "alerts": [1, 2]
    }
}]
getSituationAlertIds

Returns the total number of alerts, and a list of their alert IDs for a specified Situation. This can be either all alerts or just those alerts unique to the Situation.

Request Arguments

Name

Type

Description

situationId

Number

The Situation ID

uniqueOnly

Boolean

Gets alert IDs from the Situation:

true = get those alerts unique to the Situation

false = get all alerts in the Situation

Return Parameter

Type

Description

Native object

A Javascript object containing the total and the alert IDs

Example

Return:

{ 
     "total_alerts":10,
     "alert_ids":[4, 5, 6, 12, 14, 15, 16, 17, 18, 19] 
}
getSituationIds

Get all situation Ids matching the query.

Request Argument

Name

Type

Description

query

JSON Object

A JSON Object containing the alert filter information

limit

Number

The maximum number of situation ids to return

Return Parameter

Type

Description

NativeObject

A Javascript object containing the total and the Situation IDs

Example

Return:

{
     "total_situations":10,
     "sitn_ids":[4, 5, 6, 12, 14, 15, 16, 17, 18, 19]
}
getSituationHosts

Returns a list of host names for a specified Situation, either for all the alerts in the Situation or just for the unique alerts.

Hosts are the names (defined in the alerts.source field in the database) for the sources of Events.

Request Arguments

Name

Type

Description

situationId

Number

The Situation ID

uniqueOnly

Boolean

Gets host names for the Situation:

true = get those host names unique to the Situation

false = all host names in the Situation

Return Parameter

Type

Description

Native object

A Javascript array containing the host names

Example

Return:

{ 
    "hosts": [
        "server1",
        "server2",
        "server3",
        "server4",
        "server5",
        "server6",
        "server7"
    ]
}
getSituationProcesses

Returns a list of process names for a specified Situation, and the primary process name, if defined.

Request Argument

Name

Type

Description

situationId

Number

The Situation ID

Return Parameter

Type

Description

Native object

A Javascript array containing the process names, and the Situation's primary process, if defined

Example

Return, with a primary process name defined:

{ 
    "processes": [
        "Process1",
        "Process2"
    ],
    "primary": "Process2"
}
getSituationServices

Returns a list of external service names for a specified Situation, and the primary service name, if defined.

Request Argument

Name

Type

Description

situationId

Number

The Situation ID

Return Parameter

Type

Description

Native object

A Javascript array containing the service names, and the Situation's primary service, if defined

Example

Return, with a primary service name defined:

{ 
    "services": [
        "Service1",
        "Service2"
    ],
    "primary": "Service1"
}
getSituationTopology

Returns the topology of all alerts connected to a Situation. This is sent as a JSON object in NetJSON format that represents the nodes affected by the Situation.

Request Argument

Name

Type

Description

sigId

Number

The Situation ID

contextLevel

Integer

Level of contextual nodes to return

topologyPropsObj

Native array

Array of node properties to be returned. Valid properties are:

  • severity: Severity of the node.

  • prc: Whether this node is the probable root cause of the alert.

  • service: Service affected by the node.

  • context: Number of contextual hops between this node and a node directly affected by the Situation. A context of 0means that the node is directly affected.

  • description: Description of the node.

  • vertex_entropy: Vertex Entropy of the node.

fieldName

String

Attribute of the alert that defines the node. The default is the alert 'source' but you can specify any valid alert field, including custom_info attributes.

Return Parameter

Type

Description

Object

A JSON object in NetJSON format that represents the nodes affected by the Situation.

Example

Return, with a primary service name defined:

{
    "links": [
        {
            "source": "host2728",
            "target": "host2736"
        },
        {
            "source": "host2728",
            "target": "host1156"
        },
        {
            "source": "host2835",
            "target": "host2728"
        },
        {
            "source": "host2801",
            "target": "host2827"
        },
        {
            "source": "host2800",
            "target": "host2801"
        },
        {
            "source": "host2801",
            "target": "host2835"
        },
        {
            "source": "host2835",
            "target": "host2736"
        }
    ],
    "nodes": [
        {
            "id": "host2835",
            "properties": {
                "severity": 5,
                "prc": 0.9862626716344282,
                "service": "",
                "context": 0,
                "description": "",
                "vertex_entropy": 0.1794592472207979
            }
        },
        {
            "id": "host2736",
            "properties": {
                "severity": 4,
                "prc": 0.42722191049803876,
                "service": "",
                "context": 0,
                "description": "",
                "vertex_entropy": 0.08976540495989357
            }
        },
        {
            "id": "host2728",
            "properties": {
                "severity": 3,
                "prc": 0.007672752075071621,
                "service": "",
                "context": 0,
                "description": "",
                "vertex_entropy": 0.1794592472207979
            }
        },
        ]
}
getTeams

A GET request that returns all teams created in the Moogsoft AIOps instance.

Request Arguments

Name

Type

Description

auth_token

String

A valid auth_token returned from the authenticate request.

Return Parameters

Type

Description

Native Object

A native object containing information about all teams in Moogsoft AIOps.

Example

Curl Command:

curl -G -u graze:graze -k -v "https://localhost/graze/v1/getTeams"

Successful request return:

[
    {
        "room_id": 1,
        "alert_filter": "",
        "user_ids": [
            3
        ],
        "sig_filter": "",
        "landing_page": "",
        "description": "Example Team",
        "active": true,
        "team_id": 1,
        "services": [
            "Commerce",
            "Compute",
            "CRM",
            "Database",
            "Mobile",
            "Networking",
            "Remote",
            "Social",
            "Storage",
            "Switch",
            "Web"
        ],
        "users": [
            "admin"
        ],
        "name": "Cloud DevOps",
        "service_ids": [
            1,
            2,
            3,
            4,
            5,
            6,
            7,
            8,
            9,
            10,
            11
        ]
    },
    {
        "room_id": 2,
        "alert_filter": "",
        "user_ids": [
            3,
            5,
            7
        ],
        "sig_filter": "",
        "landing_page": "",
        "description": "",
        "active": true,
        "team_id": 2,
        "services": [
            "Compute",
            "Mobile",
            "Remote",
            "Storage",
            "Switch"
        ],
        "users": [
            "admin",
            "1",
            "3"
        ],
        "name": "DatabaseOps",
        "service_ids": [
            3,
            5,
            7,
            9,
            10
        ]
    }
]
getTeam

A GET request that returns a team's details by team ID or name.

Request Arguments

Name

Type

Description

auth_token

String

A valid auth_token returned from the authenticate request.

team_id

Integer

ID of the team to retrieve information about.

name

String

Name of a valid team to retrieve information about.

Return Parameters

Type

Description

JSON Object

A JSON Object containing details about the team.

Examples

Request to return the details for the team with ID 1:

var teamData = moogdb.getTeam(1);

Successful request return:

{
    "room_id": 1,
    "alert_filter": "",
    "user_ids": [
        3
    ],
    "sig_filter": "",
    "landing_page": null,
    "description": "Example Team",
    "active": true,
    "team_id": 1,
    "services": [],
    "users": [
        "admin"
    ],
    "name": "Cloud DevOps",
    "service_ids": []
}

Example 2 (name)

Curl Command to return the details for team Cloud DevOps:

curl -G -u graze:graze -k -v "https://localhost/graze/v1/getTeam?name=Cloud DevOps"

Successful request return:

{
    "room_id": 1,
    "alert_filter": "",
    "user_ids": [
        3
    ],
    "sig_filter": "",
    "landing_page": null,
    "description": "Example Team",
    "active": true,
    "team_id": 1,
    "services": [],
    "users": [
        "admin"
    ],
    "name": "Cloud DevOps",
    "service_ids": []
}
getTeamsForService

A GET request to return all teams related to the service with the specified ID or name.

Request Arguments

Name

Type

Description

auth_token

String

A valid auth_token returned from the authenticate request.

service_id

String

The ID of the service.

name

String

The name of the service.

Return Parameters

Type

Description

Native Object

A native object containing information about all teams in associated with the specified services in Moogsoft AIOps.

Examples

Curl Command for service_id:

curl -G -u graze:graze -k -v "https://localhost/graze/v1/getTeamsForService?service_id=1"

Curl command for service name:

curl -G -u graze:graze -k -v "https://localhost/graze/v1/getTeamsForService?service_name=web"

Successful request return:

[
    {
        "room_id": 1,
        "alert_filter": "",
        "user_ids": [
            3
        ],
        "sig_filter": "",
        "name": "Cloud DevOps",
        "landing_page": "",
        "description": "Example Team",
        "active": true,
        "service_ids": [
            1,
            2,
            3,
            4,
            5,
            6,
            7,
            8,
            9,
            10,
            11
        ],
        "team_id": 1,
        "services": [
            "Commerce",
            "Compute",
            "CRM",
            "Database",
            "Mobile",
            "Networking",
            "Remote",
            "Social",
            "Storage",
            "Switch",
            "Web"
        ],
        "users": [
            "admin"
        ]
    }
]
getTeamSituationIds

Get all situation Ids for the given team.

Request Argument

Name

Type

Description

teamName

String

The team name

limit

Number

The number of situations to return

Return Parameter

Type

Description

NativeObject

A Javascript object containing the total and the Situation IDs

Example

Return:

{
     "total_situations":10,
     "sitn_ids":[4, 5, 6, 12, 14, 15, 16, 17, 18, 19]
}
getThreadEntries

Returns thread entries for the specified Situation. Threads are comments or 'story activity' on Situations.

You can select specific thread entries to return using start and limit values. If not, the first 100 entries will be returned. The entries returned are ordered by most recent entries first.

Request Arguments

Name

Type

Required

Description

situationId

Number

Required

Situation ID.

thread

String

Required

Name of the thread.

start

Number

Optional

Number of the first thread entry to return.

limit

Number

Optional

Maximum number of thread entries to return.

Return Parameter

Type

Description

Native object

A Javascript object containing details of the selected thread entries

Examples

Request to get the thread entries for thread "Support" on Situation ID 58:

var threadEntries = moogdb.getThreadEntries(58, “Support”, 0, 10);

Successful return:

{ 
  "entries": [
              {
                  "uid": 3,
                  "entry": "This one is important. Another comment",
                  "agrees": [],
                  "total_comments": 0,
                  "thread_id": "Support",
                  "mmid": -1,
                  "sig_id": 58,
                  "entry_id": 2,
                  "timed_at": 1423226829,
                  "disagrees": [],
                  "commenters": []
              },
              {
                  "uid": 3,
                  "entry": "No comment. A comment",
                  "agrees": [],
                  "total_comments": 0,
                  "thread_id": "Support",
                  "mmid": -1,
                  "sig_id": 58,
                  "entry_id": 1,
                  "timed_at": 1423226807,
                  "disagrees": [3],
                  "commenters": []
              }
             ],
  "total_entries": 2
}
getUser

Fetches user information from the database, given the user ID or username.

Request Argument

Name

Type

Description

userId

Number

A valid user ID

username

String

A valid username

Return Parameter

Type

Description

CEvent

A CEvent object containing the user information

Example:

Example request:

var cevent = moogdb.getUser(6);

Example response:

{active=true, competencies=[], contact_num=, department=null, description=Online, email=, fullname=cyber, groupname=End-User, invitations=[], joined=1516963803, only_ldap=0, photo=-1, primary_group=1, profile_image=null, realms=[DB], roles=[1, 3, 4, 5], session_expiry=null, status=1, teams=[], timezone=SYSTEM, uid=6, username=cyber}
getUsers

Fetches all users from the database.

Request Argument

Name

Type

Description

limit

Integer

The number of users to return. 1000 by default.

Return Parameter

Type

Description

NativeObject

A JavaScript list of objects describing the users.

Example

Return:

[
    {
        "uid": 3,
        "teams": [
            "Cloud DevOps"
        ],
        "fullname": "Administrator",
        "username": "admin"
    },
    {
        "uid": 6,
        "teams": [],
        "fullname": "Nagios",
        "username": "Nagios"
    },
    {
        "uid": 5,
        "teams": [],
        "fullname": "Webhook",
        "username": "Webhook"
    }
  ]
getUserName

Fetches user information from the database, given the user ID.

Request Argument

Name

Type

Description

userId

Number

A valid user ID

Return Parameter

Type

Description

String

The corresponding username for the submitted user ID.

getUserRoles

Fetches the user's roles from the database.

Request Argument

Name

Type

Description

userid

Number

A valid userId

username

String

A valid username

Return parameter

Type

Description

NativeObject

A JavaScript object containing Role id, Role name and Role description

Example

Return:

[{
        "id": 1,
        "name": "Super User",
        "description": "Super User"
}, {
        "id": 3,
        "name": "Manager",
        "description": "Manager"
}, {
        "id": 4,
        "name": "Operator",
        "description": "Operator"
}]
getUserTeams

Fetches the user IDs and team names for a specified user in the database.

Request Argument

Name

Type

Description

userid

Number

A valid user ID.

username

String

A valid username

Return parameter

Type

Description

CEvent

A CEvent containing the team IDs and team names.

[{
        "id": 2,
        "name": "Alpha"
}, {
        "id": 3,
        "name": "Epsilon"
}, {
        "id": 4,
        "name": "Moo_team"
}]
getWorkflowEngineMoolets

Request Arguments

None.

Return Parameter

A JSON array of moolet objects. Each object has the following:

Name

Type

Description

moolet_name

String

The Moolet name.

moolet_type

ENUM/String

The Moolet type: event, alert, or situation.

active

Boolean

Is the workflow engine that the Moolet represents active?

functions[c][d][e]

JSON

The available functions in the moobot - each key is the function name and the values are:

  • Description (String) -- The description of the function

  • Decision (Boolean) -- If True, treat the result of this function as a decision,.

  • Arguments - (JSON) the arguments of the function, a map from the argument name to:

    • Type - (ENUM/String) the type of argument - either Text, JSON or Number.

    • Description - Human readable description of the argument.

last_updated

Integer

UNIX time when the Moolet was last updated.

Example

[{
    "moolet_name": "Alerts Workflows",
    "moolet_type": "alert",
    "active": true,
    "functions": {
            "functionOne": {
                    "description": "The first function",
                    "decision": true,
                    "arguments": {
                            "severity": {
                                    "type": "Number",
                                    "description": "The severity."
                            }
                    }
            },
            "functionTwo": {
                    "description": "The second function",
                    "decision": false,
                    "arguments": {
                            "customInfo": {
                                    "type": "JSON",
                                    "description": "The custom info."
                            },
                            "key": {
                                    "type": "Text",
                                    "description": "The key within the custom info."
                            }
                    }
            }
    },


    "last_updated": 1545306590
}]
getWorkflows

Get all the known workflows by moolet name.

Request Arguments

Name

Type

Description

mooletName

String

Required

Name of the moolet to retrieve workflows for.

activeOnly

Boolean

Return only the active workflows.

Return Parameter

JSON array of matching workflows, where each has:

Type

Type

Description

id

Integer

Unique ID of the workflow.

moolet_name

String

Moolet name.

workflow_name

String

Workflow name.

sequence

Integer

Workflow sequence.

active

Boolean

Is the workflow active?

description

String

Workflow description.

entry_filter

JSON filter

The entry filter of the Workflow (null indicates accept all)

sweep_up_filter

JSON filter

Check the database for all objects that match the filter criteria and pass them to all workflow actions as a list parameter. The sweep-up filter expedites entry of related objects into the workflow. For example: if you receive a link-up alert, you can set a filter to retrieve all related link-down alerts from the database and have the sweep up filter close them.

A null argument indicates no sweep-up filter.

first_match_only

Boolean

If true, perform workflow operations only once on each object.

operations

JSON list

An ordered list of operations, where position on the list is the order of execution. Each operation will have:

  • type (ENUM/String) -- The type of the operation: action, decision, or delay. This method reads other JSON fields depending on the type.

  • operation_name (String) -- Type is action/decision the name of the operation

  • function_name (String) -- Action or decision types only

  • function_args (Object) -- Action or decision types only

  • duration (Integer) -- The amount of seconds before the message goes to the next operation/Workflow/moolet (delay type only)

  • reset (Boolean) -- Whether to reset the timer on each occurrence (delay type only)

Example

[{
    "id": 1,
    "moolet_name": "Alerts Workflows",
    "workflow_name": "ChangeInfoWorkflow",
    "sequence": 1,
    "active": true,
    "description": "Changingthealertinformation",
    "entry_filter": {
            "column": "severity",
            "op": 5,
            "value": 3,
            "type": "LEAF"
    },
    "sweep_up_filter": {
            "column": "description",
            "op": 4,
            "value": "description",
            "type": "LEAF"
    },
    "first_match_only": true,
    "operations": [{
                    "type": "action",
                    "function_name": "functionA",
            "operation_name": "Name of operation",
                    "function_args": {
                            "admin": 2
                    }
            },
            {
                    "type": "delay",
                    "delay": 30,
            "reset": false
            }
    ]
}]

mergeSituations

Merges two or more Situations, superseding the originals if required, and returning the newly created Situation.

Request Arguments

Name

Type

Description

situationIds

Native array

A Javascript array containing the IDs of the Situations to merge

keepOriginals

Boolean

Determines what to do with the original Situations:

true = keep the original Situations

false = supersede the original Situations

Return Parameter

Type

Description

CEvent

A CEvent object containing the newly created Situation

moveSituationToCategory

Move a Situation into a new category.

A category represents a type of Situation, indicating how it was created or its state. See Create Shared Alert and Situation Filters for more information.

Request Arguments

Name

Type

Description

situationId

Number

The Situation ID

category

String

The name of the new category

Return Parameter

Type

Description

Boolean

Indicates if the operation was successful: true = success, false = fail

moveSituationToQueue

Assigns a specified Situation to a queue and writes a thread entry if required. The queue and user may be provided as either an ID or a valid name.

Request Arguments

Name

Type

Description

situationId

Number

The Situation ID

user

Object

An object containing either a valid user name or ID

queue

Object

An object containing either a valid queue name or ID

journal

String

An entry to add to the journal thread, if required

Optional

Return Parameter

Type

Description

Boolean

Indicates if the operation was successful: true = success, false = fail

removeAlertFromSituation

Removes a specified Alert from a Situation.

Request Arguments

Name

Type

Description

alertId

Number

The Alert ID

situationId

Number

The Situation ID

Return Parameter

Type

Description

Boolean

Indicates if the operation was successful: true = success, false = fail

removeSigCorrelationInfo

Removes all correlation information related to a specified Situation.

Request Arguments

Name

Type

Description

auth_token

String

A valid auth_token returned from the authenticate request.

sitn_id

Number

The Situation ID

serviceName

String

The service name (Optional).

externalId

String

The external ID (Optional).

Return Parameter

Type

Description

Boolean

Indicates if the operation was successful: true = success, false = fail

reorderWorkflows

Reorder the sequence of Workflows within a Moolet.

Request Arguments

Argument

Type

Description

moolet_name

String

Required -- Moolet name.

workflow_IDs_sequence

Array of Integers

Required -- An ordered array of all the workflow IDs, where position 0 is the first ID in the sequence.

Return Parameters

Type

Description

Boolean

True if the operation was successful.

Example

moogdb.reorderWorkflows(“Alerts Workflows”, [1, 4, 3, 2, 5]);
resolveSituation

Resolve a specified Situation that is currently open.

Request Argument

Name

Type

Description

situationId

Number

The Situation ID

Return Parameter

Type

Description

Boolean

Indicates if the operation was successful: true = success, false = fail

reviveSituation

Revive (set to open) a specified Situation that is currently set to resolved.

Request Argument

Name

Type

Description

situationId

Number

The Situation ID

Return Parameter

Type

Description

Boolean

Indicates if the operation was successful: true = success, false = fail

setAlertCustomInfo

Updates the custom information in the database for specified Alert.

This method can either be used with the alertInfo CEvent or with both the alertID and customInfoMap arguments.

The merge parameter can be used alongside either methods. This determines whether to merge the new custom information data with existing data or replace it.

Request Arguments

Name

Type

Description

alertId

Number

The Alert ID.

Note

Can be used alongsidecustomInfoMapandmergebut notalertInfo.

alertInfo

CEvent

A CEvent containing alert_id and custom_infoattributes, the values of which will be used to replace the custom_info in the specified Alert.

Note

Can be used alongsidemergebut notalertIdorcustomInfoMap.

customInfoMap

Object

A map of name value pairs containing the new custom_info information.

merge

Boolean

Determines what is done with the custom information:

true = merge the existing data with the new data

false = replace the existing data with the new data.

Return Parameter

Type

Description

Boolean

Indicates if the operation was successful: true = success, false = fail.

setAlertSeverity

Sets the severity level for a specified Alert.

Request Arguments

Name

Type

Description

alertId

Number

The Alert ID

severity

Number

The Alert's severity as an integer:

0

Clear

1

Indeterminate

2

Warning

3

Minor

4

Major

5

Critical

Return Parameter

Type

Description

Boolean

Indicates if the operation was successful: true = success, false = fail.

setPrcLabels

Updates the probable root cause (PRC) information for specified alerts within a Situation. You must specify at least one alert ID and a PRC level for the alert.

You can mark alerts as causal, non_causal or unlabelled within a Situation. An alert can have different PRC levels within different Situations.

Request Arguments

Name

Type

Description

situationId

Number

The Situation ID

alert_ids

JSON list

A list of the alert IDs

causal
non_causal
unlabelled

JSON list

PRC levels

Input example:

var prcLabels = { causal: [1], unlabelled: [4], non_causal: [2,3] };
moogdb.setPrcLabels(1, prcLabels);

Return Parameter

Type

Description

Boolean

Indicates if the operation was successful: true = success, false = fail

setResolvingThreadEntry

Sets or clears a thread entry in a Situation as a resolving step. Threads are comments or 'story activity' on Situations.

This method returns a Boolean indicating whether the thread entry was successfully set or cleared as a resolving step.

Request Arguments

Name

Type

Required

Description

entryId

Number

Yes

ID of the thread entry.

resolving_step

Boolean

Yes

Whether you are setting or clearing the thread entry as a resolving step.

userId

Number

Yes

A valid user ID.

Return Parameter

Type

Description

Boolean

Whether or not the thread entry was successfully set or cleared as a resolving step.

Examples

Request to set thread entry 32 as a resolving step using user ID 1:

var success = moogdb.setResolvingThreadEntry(32, true, 1);

Return of successful request:

true
setSigCustomInfo

Updates the custom information in the database for specified Situation.

The Situation ID and new custom information are both contained in the situationInfo CEvent.

The new custom information is contained in the customInfoMap object.

The merge parameter determines whether to merge the new custom information data with existing data or replace it.

Request Arguments

Name

Type

Description

situationId

Number

The Situation ID

customInfoMap

Object

A map of name value pairs containing the new custom_info information.

merge

Boolean

Determines what is done with the custom information:

true = merge the existing data with the new data

false = replace the existing data with the new data

Return Parameter

Type

Description

Boolean

Indicates if the operation was successful: true = success, false = fail

setSituationProcesses

Applies a list of processes (contained in the processes Javascript array) to a specified Situation.

Any other processes already associated with the Situation are removed.

Request Arguments

Name

Type

Description

situationId

Number

The Situation ID.

processes

Native array

A Javascript array containing the process names. If any processes supplied do not exist in the database, they are created and assigned to the Situation.

Return Parameter

Type

Description

Boolean

Indicates if the operation was successful: true = success, false = fail

setSituationServices

Applies a list of external services (contained in the services JavaScript array) to a specified Situation.

Any other services already associated with the Situation are removed.

Request Arguments

Name

Type

Description

situationId

Number

The Situation ID.

services

Native array

A JavaScript array containing the service names. If any services supplied do not exist in the database, they are created and assigned to the Situation.

Return Parameter

Type

Description

Boolean

Indicates if the operation was successful: true = success, false = fail

updateAlert

Takes an Alert object and uses it to update the database and the MooMS bus.

Request Argument

Name

Type

Description

alertObject

CEvent

The Alert object

Return Parameter

Type

Description

Boolean

Indicates if the operation was successful: true = success, false = fail

updateCustomInfo

Update the custom info for an alert or Situation.

Request Argument

Name

Type

Description

toUpdate

CEvent

A CEvent representing the alert or Situation you want to update.

toMerge

JavaScript Object

The custom info to add to/replace the existing custom info field.

merge

Boolean

Merge the existing and new custom info if true. Replaces existing custom info if false. Defaults to true.

For an alert you can also use the following arguments:

Name

Type

Description

alertId

Number

Alert ID of the alert you want to add custom info to.

path

String

Dot-notation path to the custom_info key where the info is stored. Updates existing value if the key already exists; creates the full path if the key does not exist.

param

Value

Value to put at the specified key.

Return Parameter

Type

Description

Boolean

Indicates if the operation was successful. True = success, false = fail.

updateMaintenanceWindow

Updates a maintenance window object, by passing an object containing the maintenance window information.

Request Argument

Name

Type

Required

Description

updatedWindow

Native object

Yes

Maintenance window object containing the updated details.

The maintenance window object maintenanceWindowObj contains the following information:

Name

Type

Required

Description

window_id

Number

Yes

ID of the maintenance window.

name

String

Yes

Name of the maintenance window.

description

String

Yes

Description of the maintenance window.

filter

String

Yes

Filter to apply to the new alerts created.

start_date_time

Number

Yes

The time in epoch when the maintenance window will start, up to a maximum of 5 years in the future.

duration

Number

Yes

Duration, in seconds, that the maintenance window will run for. Must be greater than zero.

forward_alerts

Boolean

Yes

Whether or not alerts will be forwarded to a Situation.

recurring_period

Number

No

Whether or not this is a recurring maintenance window. Set this to:

  • 1 for a recurring maintenance window.

  • 0 for a one-time maintenance window.

If you change this from 0 to 1, you must specify recurring_period_units.

recurring_period_units

Number

No

Specifies the recurring period of the maintenance window, in days, weeks or months. If you set recurring_period to 0, you must set recurring_period_units to 0. Valid values are:

  • 0 = a one-time maintenance window

  • 2 = daily

  • 3 = weekly

  • 4 = monthly

Example

Request to update a maintenance window:

var updatedWindow = moogdb.updateMaintenanceWindow(windowToUpdate)

Where windowToUpdate is as follows:

{
  “window_id”:351, 
  “name”:“Updated name”, 
  “description”:“Updated Description”, 
  “filter”:“source = \“server1\“”, 
  “start_date_time”:1546433400, 
  “duration”:3600, 
  “forward_alerts”:false, 
  “recurring_period”:1, 
  “recurring_period_units”:3
}
updateSituation

Takes a Situation object and uses it to update the database and the Message bus.

Request Argument

Name

Type

Description

situationObject

CEvent

The Situation object

Return Parameter

Type

Description

Boolean

Indicates if the operation was successful: true = success, false = fail

updateTeam

Update the team, by passing an object containing team information.

Request Arguments

Name

Type

Description

teamObj

Object

A map containing the following team information

team_id

Number

Mandatory - The team ID

name

String

Optional - The new team name. Leave empty to leave Moogsoft AIOps as is

alert_filter

String

Optional - The new team alerts filter. Either a SQL like filter or an JSON representation of the filter. Leave empty to leave Moogsoft AIOps as is

services

JSON List

Optional - List of the team services names or IDs. Leave empty to leave Moogsoft AIOps as is

sig_filter

String

Optional - The situation filters. Either a SQL like filter or an JSON representation of the filter. Leave empty to leave Moogsoft AIOps as is

landing_page

String

Optional - The team default landing page. Leave empty to leave Moogsoft AIOps as is

active

Boolean

Optional - False if the team is inactive, true if the team is active. Default to true. Leave empty to leave Moogsoft AIOps as is

description

String

Optional - The team description. Leave empty to leave Moogsoft AIOps as is

users

List of numbers or strings

Optional - The team users (either IDs or usernames). Leave empty to leave Moogsoft AIOps as is

Input example

{
    "team_id" : 3,
        "name": "myTeam",
        "alert_filter": "{ \"column\": \"count\", \"op\": 1, \"value\": 1, \"type\": \"LEAF\" }",
        "sig_filter": "{ \"column\": \"severity\", \"op\": 1, \"value\": 5, \"type\": \"LEAF\" }",
        "active": true,
        "services": [1, 2, 4],
        "users": ["user1", "user4"],
        "description": "myDescription",
        "landing_page": ""
}

Return Parameter

Type

Description

Boolean

Indicates if the operation was successful: true = success, false = fail

updateUser

Update the user, by passing an object containing user information.

Request Arguments

Name

Type

Description

userObj

Object

A map containing the following user information

username

String

Mandatory (optional if user id used) - the user login username

uid

Number

Mandatory (optional if username used) - the user id

password

String

The new user password (only valid for DB realm)

active

Boolean

true if the user active, false if the user inactive, default to true

email

String

The user email address

fullname

String

The user full name

roles

JSON list

List of user roles. That list should contain either the list the role IDs or the role names. For example, "roles":["Super User"],

primary_group

String or Number

The user primary group name or primary group id

department

String or number

The user department id or name

timezone

String

The user timezone

contact_num

String

The user phone number

session_expiry

Number

The number of minutes after which the user session will expire. Default to system default

competencies

JSON list

A list with the user competencies. Each competency should have the name or cid and ranking. That is, something like:

[
     { "name" : "SunOS" ,  "ranking" :  40 },
     { "name" : "SAP" ,  "ranking" :  50 },
     { "name" : "EMC" ,  "ranking" :  60 }
]
teams

JSON list of numbers or strings

List of the user teams. The list should contains either the list of the teams ID or the teams name.

Input example :

{
        "uid": 5,
        "fullname": "firstName surName",
        "competencies": [{
                        "name": "SunOS",
                        "ranking": 40
                },
                {
                        "name": "SAP",
                        "ranking": 50
                },
                {
                        "name": "EMC",
                        "ranking": 60
                }
        ],
        "roles": ["Super User"],
        "department": 3,
        "active": true,
        "email": "user@email.com",
        "timezone": "a timezone",
        "teams": [1, 2, 4],
        "joined": 12345678,
        "contact_num": "0965412345"
}

Return Parameter

Type

Description

Boolean

Indicates if the operation was successful: true = success, false = fail

updateWorkflows

Update one or more existing workflows.

Request Arguments

Name

Type

Description

id

integer

The ID of the workflow to be updated.

details

JSON

A details object with the following fields.

Details Object

Name

Type

Description

workflow_name

String

Workflow name.

active

Boolean

If true, the workflow is active.

description

String

Workflow description.

entry_filter

Filter in JSON or SQL format

The sweep-up filter. An empty, null, or missing filter means no sweep-up.

first_match_only

Boolean

Perform workflow operations only once on each object.

sweep_up_filter

Filter in JSON or SQL format

The sweep-up filter. An empty, null, or missing filter means no sweep-up.

operation

JSON list

A list of operations, each being:

  • type - (ENUM/String) (Mandatory) the type of the operation. Either action, decision, delay. Depending on the type, we’ll read other fields in the JSON

  • operation_name - (String, Required for action/decision type) The operation name.

  • * function_name - (String, Required for action/decision type) The function name.

  • * function_args - (JS Object) (Optional for action/decision type) The arguments for the action or decision function.

  • duration - (Integer) (Required for delay type) The amount of seconds before the message goes to the next operation/Workflow/moolet

reset

Boolean

Mandatory for delay type

Return Parameter

Type

Description

Boolean

True if the operation was successful.

Request Example

moogdb.updateWorkflows(1, {workflow_name: “new name”});