Skip to main content

getSituationDetailsForAlert

A Workflow Engine function that retrieves the specified Situation attributes for the Situation that the triggering alert belongs to, and writes these details into the WorkflowContext for use in subsequent actions.

This function uses the alerts Active Situations list (active_sig_list). For each active Situation in the list, it will create a corresponding entry in workflowContext.situationDetails.

This function is available as a feature of the Add-ons v2.4 download and later.

This function is available for alert workflows.

Back to Workflow Engine Functions Reference.

Accessing Details With workflowContext

workflowContext.situationDetails will always be a list (an array). Situation details will be added to this list according to their Situation ID, starting from the lowest first.

The details of an alert in a single Situation can be accessed in subsequent actions using a reference of:

$(workflowContext.situationDetails[0].<name>)

where <name> is the name of the Situation attribute you want to reference.

For example, to get the Situation ID (sig_id) of the Situation you would use:

$(workflowContext.situationDetails[0].sig_id)

The list of attributes to retrieve is defined using the macro/substitution syntax. For example, to retrieve the description, moderator username and textual severity, you would use the following syntax:

[ "$(description)", "$EXPAND(moderator_id)", "$EXPAND(internal_priority)"]

Note

Entries in the details list that do not conform to the macro/substitution syntax will be ignored.

Arguments

Workflow Engine function getSituationDetailsForAlert takes the following arguments:

Name

Required

Type

Description

details

yes

object

A list of substitution syntax attributes to retrieve for the active Situations for the alert.

sig_id is always added to this list and will always be included in the results.

Example

The following example demonstrates typical use of Workflow Engine function getSituationDetailsforAlert.

Given an alert, we want to retrieve the following attributes for its active Situations:

  • description

  • moderator_id as a username

  • severity as a textual name

  • custom_info.situationClass

The details parameter would contain:

{"details":["$(custom_info.situationClass)","$EXPAND(moderator_id)","$EXPAND(internal_priority)","$(description)"]}

This would produce a workflowContext containing:

 {
    "situationDetails": [
        {
            "custom_info": {
                "situationClass" : "DefaultCookbook.sameSource"
            },
            "moderator_id": "admin",
            "internal_priority": 2,
            "description": "Topology based :  Affecting 8 hosts. ",
            "sig_id": 470
        }
    ]
}