Step-2: Native Data-format
B1: Variables: Set Primitive Variable - Store webhook payload
The data and context passed by the external/third-party entity through the HTTP-request is not in a native Runbook format. The data and context must be converted into a native data format so the Runbook can properly process the data and context while the Runbook executes.
You can use the Variables: Set Primitive Variable node to parse data and context from the HTTP-request into Runbook runtime-variables. The Runbook runtime-variables persist for the duration of the Runbook execution. The automation can use these variables throughout the process.
The Variables: Set Primitive Variable node employs a Liquid template to define how to parse data and context out of the HTTP-request and into Runbook runtime-variables according to the Template defined in section “Template to Assign Value to Variables” of the Variables: Set Primitive Variable node.
PREREQUISITE:
Prior to configuring the Variables: Set Primitive Variable node, the Runbook runtime-variables intended to hold the HTTP-request data and context must first be configured.
Runbook runtime-variables are configured in the Runbook Editor by:
-
Selecting the Variables menu-item (i.e. (x) ) (Edit the variables used in the Runbook) to open the Runbook Variable pop-up.
-
In the Runbook Variable pop-up: for each data/context element in the HTTP-request that need to be processed by the Runbook:
-
Under Runtime Scope, click Add a Runtime Variable to create a runtime variable (with appropriate Name, Type, Unit, and Default value) to describe/hold that element.
-
-
When all data/context elements of interest in the HTTP-request have an associated runtime-variable: click “Save & Close”.
For example,
-
One data/context element in HTTP-request is:
-
{ "alert_id": 1}
-
-
The associated Runbook runtime-variable for storing this information in native data-format is:
Placement of the Variables: Set Primitive Variable node in the Runbook Editor
There are two methods to place the Variables: Set Primitive Variable node in the canvas of the Runbook Editor.
-
Find the Variables: Set Primitive Variable node in the palette on the left-side of the Runbook Editor and drag it onto the canvas to the right of the Triggering Entity: Webhook node.
-
The Triggering Entity: Webhook node provides the data and context input for the Variables: Set Primitive Variable node. Connect the data flow from Triggering Entity: Webhook to Variables: Set Primitive Variable.
-
-
Alternatively, click the plus sign on the Triggering Entity: Webhook node to reveal a pop-up menu of relevant nodes and find/select the Triggering Entity: Webhook node.
Configuration of the Node to Parse data from HTTP-request into Runbook-runtime variables
-
In the Variables: Set Primitive Variable editor card on the right, go to the “Variables to Set” area and:
-
Press “Set another Variable” to begin process of adding all of the predefined Runbook-runtime variables (defined to hold associated HTTP-request content) to this node:
-
For each variable being added, ensure Scope: Runbook execution is selected.
-
Then find the specific Variable Name.
-
-
Repeat this process until every predefined Runbook runtime variable (defined to hold associated HTTP-request content) are added to this node.
-
-
Next, the “Template to Assign Value to Variables” area must be configured.
NOTE: This area of the node configuration uses Liquid-templates to define data formats. Refer to Working With Liquid Templates.-
This Webhook and its associated HTTP-request use the following Liquid template to map the HTTP-request content into an associated Runbook runtime variable.
Click to reveal template
Copy{% assign body = trigger['requestBody'] %}
{
"runtime.alert_id": {{ body["alert_id"] }},
"runtime.alert_name": "{{ body["alert_name"] }}",
"runtime.alert_event_name": "{{ body["alert_event_name"] }}",
"runtime.alert_timestamp": "{{ body["alert_timestamp"] }}",
"runtime.alert_timestamp_epoch": {{ body["alert_timestamp_epoch"] }},
"runtime.urgency": "{{ body["urgency"] }},",
"runtime.impact": "{{ body["impact"] }},",
"runtime.category": "{{ body["category"] }},",
"runtime.identifier": "{{ body["identifier"] }},",
"runtime.last_event_details": "{{ body["last_event_details"] }},",
"runtime.last_event_timestamp": "{{ body["last_event_timestamp"] }},",
"runtime.last_event_timestamp_epoch": {{ body["last_event_timestamp_epoch"] }},
"runtime.device_name": "{{ body["device_name"] }},",
"runtime.device_type": "{{ body["device_type"] }},",
"runtime.device_manufacturer": "{{ body["device_manufacturer"] }}",
"runtime.device_model": "{{ body["device_model"] }}",
"runtime.device_memory": "{{ body["device_memory"] }}",
"runtime.device_cpu_cores": "{{ body["device_cpu_cores"] }}",
"runtime.device_cpu_frequency": "{{ body["device_cpu_frequency"] }}",
"runtime.device_last_booted": "{{ body["device_last_booted"] }}",
"runtime.device_last_booted_epoch": {{ body["device_last_booted_epoch"] }},
"runtime.username": "{{ body["username"] }}",
"runtime.user_domain": "{{ body["user_domain"] }}",
"runtime.user_department": "{{ body["user_department"] }}",
"runtime.user_email_address": "{{ body["user_email_address"] }}",
"runtime.user_title": "{{ body["user_title"] }}",
"runtime.os_name": "{{ body["os_name"] }}",
"runtime.business_location": "{{ body["business_location"] }}",
"runtime.subnet": "{{ body["alersubnett_id"] }}",
"runtime.custom_attribute_1": "{{ body["custom_attribute_1"] }}",
"runtime.custom_attribute_2": "{{ body["custom_attribute_2"] }}",
"runtime.custom_attribute_3": "{{ body["custom_attribute_3"] }}",
"runtime.custom_attribute_4": "{{ body["custom_attribute_4"] }}",
"runtime.custom_attribute_5": "{{ body["custom_attribute_5"] }}",
"runtime.custom_attribute_6": "{{ body["custom_attribute_6"] }}"
}
-
-
Click “Save & Close” to save this node configuration.
Variables: Set Primitive Variable: Configured (and Customized)