Page tree
Skip to end of metadata
Go to start of metadata

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 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 Message Bus, so any updated information automatically appears in 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

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

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

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

addProcess()

Adds a new process to the database.

Processes are external business entities related to business activities that are affected by the incidents that Moog 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

addService()

Adds a new external service to the database.

An external service is a business entity monitored by Moog 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

 assignAlert

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
StringA valid user name

Return Parameter

Type

Description

Boolean

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

 assignAndAcknowledgeAlert

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
StringA valid user name

Return Parameter

Type

Description

Boolean

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

 assignAndAcknowledgeSituation

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
StringA valid user name

Return Parameter

Type

Description

Boolean

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

 assignModerator

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
StringA valid user name

Return Parameter

Type

Description

Boolean

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

 closeAlert

closeAlert()

Closes an Alert.

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

 closeSituation

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

createAlert()

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

Request Arguments

Name

Type

Description 

alert
Native objectA Javascript object containing Alert attributes, such as typeseverity, etc
event

CEvent

A CEvent object representing the Alert, containing Alert attributes, such as typeseverity, 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

createMaintenanceWindow()

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


Request Arguments

Name

Type

Description 

maintenanceWindowObjObjectA 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
booleanMandatory -whether the alert will be forwarded to situation or not
recurring_period
NumberOptional - How many days/weeks/months to wait before this recurs. The recurring_period property must be 1 - no other value will be accepted
recurring_period_unit
NumberOptional - Decides what the recurring period counts in 0 = minutes, 1 = hours, 2 = days, 3 = weeks, 4 = months. 
The recurring_period_units property has allowed values of 2 (daily), 3 (weekly) or 4 (monthly) - no other values will be accepted

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_unit": 2
}

Return Parameter

Type

Description

Number

The window id created, or null if an error occured

 createSituation

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

createTeam()

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

Request Arguments

Name

Type

Description 

teamObjObjecta map containing the following parameters
name

String

Mandatory - the new team (unique) name

alert_filterString

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

servicesJSON listOptional - List of the team services names or IDs
sig_filterStringOptional - The situation filters. Either a SQL like filter or an JSON representation of the filter
landing_pageStringOptional - The team default landing page
activeBooleanOptional - False if the team is inactive, true if the team is active. Default to true
descriptionStringOptional - The team description
usersList of numbers or stringsOptional - 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

Number

The team id created, or null if an error occured

 createThread

createThread()

Creates a new thread for a Situation.

Threads are comments or 'story activity' on Situations (More information here).

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

createThreadEntry()

Creates an entry on the specified thread.

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

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
Booleantrue if the user active, false if the user inactive, default to true
email
StringThe user email address
fullname
StringThe user full name
roles
JSON listMandatory - 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 NumberThe user primary group name or primary group id
department
String or numberThe user department id or name
joined
NumberThe time the user joined (in Unix time)
timezone
StringThe user timezone
contact_num
StringThe user phone number
session_expiry
NumberThe 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 stringsList 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

Number

The user id created, or null if an error occured

 deAssignAlert

deAssignAlert()

Deassigns an alert. The user assigned to the alert is removed, and the user is set to ANON.

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

deleteMaintenanceWindow()

Delete an existing 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

 deleteMaintenanceWindows

deleteMaintenanceWindows()

Delete existing maintenance windows.

Request Argument

Name

Type

Description 

filter

String

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

limit
NumberThe maximal number of windows to fetch. default to 100.

Return Parameter

Type

Description

Boolean

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

 getActiveSituationIds

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

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 typeseverity, etc

 getAlertIds

getAlertIds()

Get all alertIds matching the query.

Request Argument

Name

Type

Description 

query

JSON Object

A JSON Object containing the alert filter information

limit
NumberThe maximum number of alert ids to return

Return Parameter

Type

Description

NativeObject

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]
}
 getSigCorrelationInfo

getSigCorrelationInfo

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

Return Parameter

Type

 Description

HTTP code

HTTP status or error code indicating request success or failure
For codes, see below

 getMaintenanceWindows

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
NumberThe number of windows to fetch

Return Parameter

Type

Description

NativeObject

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
    }
  ]
}
 findMaintenanceWindows

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
NumberThe maximal number of windows to fetch. default to 100.

Return Parameter

Type

Description

NativeObject

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

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

The queue name

 getPrcLabels

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

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

CEvent

A CEvent object representing the Situation

 getServices

getServices()

Fetches a list of services from the database.

Request Argument

Name

Type

Description 

limit

Integer

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

Return Parameter

Type

Description

CEvent

A CEvent object representing the Situation

 getSituation

getSituation()

Fetches a specified Situation from the database.

Request Argument

Name

Type

Description 

situationId

Number

The Situation ID

Return Parameter

Type

Description

CEvent

A CEvent object representing the Situation

 getSituationActions

getSituationActions()

Returns activity for specified situations. Created by passing an object with information requested.

Request Arguments

Name

Type

Description 

sitn_ids

JSON list

The Situation IDs

start

Number

Starting from which row should data be included in results

limit
NumberLimit for how many activities wanted in the output
actions
JSON listList of action_codes of actions included in the return

Return Parameter

Type

Description

Native object

A Javascript object containing the activity for specified situations

Example

Input:

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

Return:

"activities": [{
    "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

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

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
NumberThe 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

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

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

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"
}
 getTeams

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

HTTP code

HTTP status or error code indicating request success or failure. 
For codes, see below.

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

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

The ID of the team to retrieve information about.

nameStringThe name of a valid team to retrieve information about.

Return Parameters

Type

  Description

HTTP code

HTTP status or error code indicating request success or failure. 
For codes, see below.

Example 1 (team_id)

Curl Command:


curl -G -u graze:graze -k -v "https://localhost/graze/v1/getTeam?team_id=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:

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

getTeamsForService

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

Request Arguments

NameTypeDescription
auth_tokenStringA valid auth_token returned from the authenticate request.
service_idStringThe ID of the service.
nameStringThe name of the service.

Return Parameters

TypeDescription
HTTP codeHTTP status or error code indicating request success or failure. 
For codes, see below.

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

getTeamSituationIds()

Get all situation Ids for the given team.

Request Argument

Name

Type

Description 

teamName

String

The team name

limitNumberThe 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

getThreadEntries()

Returns thread entries for the specified Situation. Threads are comments or 'story activity' on Situations (More information here).

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

Description 

situationId

Number

The Situation ID

thread

String

The name of the thread

start

Number

The number of the first thread entry to return
Optional

limit

Number 

The maximum number of thread entries to return
Optional

Return Parameter

Type

Description

Native object

A Javascript object containing details of the selected thread entries

Example

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
}
 getUser

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
StringA 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

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

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

getUserRoles()

Fetches the user's roles from the database.

Request Argument

NameTypeDescription

userid

 NumberA valid userId
usernameStringA valid username

Return parameter

TypeDescription
NativeObjectA 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

getUserTeams()

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

Request Argument

NameTypeDescription

userid

 NumberA valid user ID.
usernameStringA valid username

Return parameter

TypeDescription
NativeObjectA Javascript object containing Team id and Team name
[{
	"id": 2,
	"name": "Alpha"
}, {
	"id": 3,
	"name": "Epsilon"
}, {
	"id": 4,
	"name": "Moo_team"
}]
 mergeSituations

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

moveSituationToCategory()

Move a Situation into a new category.

A category represents a type of Situation, indicating how it was created or its state. For more information, see Alert and Situation Filters.

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

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

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

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

serviceNameStringThe service name (Optional).
externalIdStringThe external ID (Optional).

Return Parameter

Type

 Description

HTTP code

HTTP status or error code indicating request success or failure
For codes, see below

 resolveSituation

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

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

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.

Can be used alongside customInfoMap and merge but not alertInfo.

alertInfo
CEvent

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

Can be used alongside merge but not alertId or customInfoMap.

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

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

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

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

 setSigCustomInfo

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

 setSituationExternalSeverity

setSituationExternalSeverity()

Sets the external severity level for a specified Situation. 

The severity level can be a number or a string, as specified in the table below.

Request Arguments

Name

Type

Description

situationId

Number

The Situation ID

severity

String

The Situation's severity as an integer or a one of the following strings:

Integer

String

0
Clear
Indeterminate 
2
Warning 
3
Minor 
4
Major 
5
Critical

Return Parameter

Type

Description

Boolean

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

 setSituationProcesses

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

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

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

 updateSituation

updateSituation()

Takes a Situation object and uses it to update the database and the MooMS 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

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_idNumberMandatory - The team ID
nameStringOptional - The new team name. Leave empty to leave Moogsoft AIOps as is
alert_filterString

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

servicesJSON ListOptional - List of the team services names or IDs. Leave empty to leave Moogsoft AIOps as is
sig_filterStringOptional - The situation filters. Either a SQL like filter or an JSON representation of the filter. Leave empty to leave Moogsoft AIOps as is
landing_pageStringOptional - The team default landing page. Leave empty to leave Moogsoft AIOps as is
activeBooleanOptional - False if the team is inactive, true if the team is active. Default to true. Leave empty to leave Moogsoft AIOps as is
descriptionStringOptional - The team description. Leave empty to leave Moogsoft AIOps as is
usersList of numbers or stringsOptional - 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

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
NumberMandatory (optional if username used) - the user id
password
String

The new user password (only valid for DB realm)

active
Booleantrue if the user active, false if the user inactive, default to true
email
StringThe user email address
fullname
StringThe user full name
roles
JSON listList 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 NumberThe user primary group name or primary group id
department
String or numberThe user department id or name
timezone
StringThe user timezone
contact_num
StringThe user phone number
session_expiry
NumberThe 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 stringsList 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