Using User Defined Variables in Runbooks

User defined variables (also known as custom variables) enable you to store and exchange data throughout your runbookClosed An automated workflow that executes a series of steps or tasks in response to a triggered event, such as the detection of anomalous behavior generating an incident, a lifecycle event, or a manually executed runbook. execution. You can use custom variables to pass information between nodesClosed Individual components that make up a runbook automation, each performing a specific function such as data queries, transformations, logic, integrations, or visualizations., store calculated values, and exchange data with external applicationsClosed An entity type representing software applications deployed in the customer environment that are monitored for performance and anomalies. like Slack or ServiceNow.

Custom variables work alongside built-in variables in runbooks. Both types of variables are accessed via the (x) button (Edit Variables) in the Runbook Editor tool bar.

Defining Custom Variables

Before you can use a custom variable in a runbook, you must define it in the Variable Definition Editor. Click the (x) button in the Runbook Editor tool bar to open the Variable Definition Editor.

In the Variable Definition Editor, you can create user-defined variables for each scope.

To add a custom variable, click the Add Variable button and choose the variable type from the pop-up menu. You can select one of the primitive types (integer, string, etc.) or an IQ Ops data type.

If you select an IQ Ops data type, you can specify if it will be one of the predefined data types like ApplicationClosed An entity type representing software applications deployed in the customer environment that are monitored for performance and anomalies. or DeviceClosed An entity type representing network devices or hardware components deployed in the customer environment that are monitored for performance and anomalies., or a fully custom type. If you choose a fully custom type, you must also specify which property and/or MetricsClosed A measurement or data point that is monitored and analyzed to detect anomalies and generate incidents. this type will use. Metrics are optional, but at least one property is required to identify the data.

For each variable, type a name and a default value, and fill in the other fields that are appropriate for that variable type (e.g., there's no Unit field for a String type variable).

Setting Variable Values

After you define a custom variable, you can set its value in your runbook using the appropriate node:

The Set Primitive Variable node uses Liquid templates to assign values. The Set Structured Variable node does not use Liquid templates. The scope is automatically added to each variable name when you use it outside the Variable Definition Editor (e.g., "runtime.MyCustomVariable").

Variable Naming and Syntax

Custom variables follow the same naming convention as built-in variables. The variable name includes the scope prefix, followed by a dot, followed by your custom variable name. For example:

When you reference a variable in a Liquid template, use the full name with the scope prefix. For example, to reference a runtime scope variable named "myInt":

{{ variables["runtime.myInt"] }}

Using Custom Variables in Runbooks

Once you've defined and set a custom variable, you can use it throughout your runbook in various ways:

In Set Variable Nodes

You can use one custom variable to set the value of another. For example, to assign a variable "myInt" to the value of another variable ("anotherInt") multiplied by two:

{

"runtime.myInt": "{{ variables["runtime.anotherInt"]| times 2}}"

}

In Decision Branch Nodes

You can use custom variables in Decision Branch nodes to route execution based on variable values. For example, in a webhook runbook, you can route to different remediation paths based on the value of a custom variable that was set from the webhook payload.

In Visualization and Incident Priority Nodes

You can use custom variables in Visualization nodes and Incident Priority nodes to display variable values in titles, notes, and priority reasons. For example:

  • In a Visualization node title: "Data From {{runtime.MyCustomVariable}}"

  • In a Visualization node note: "The result is {{runtime.MyCustomVariable}}"

  • In an Incident Priority node reason: "Priority set based on {{runtime.AlertSeverity}}"

Note: Only primitive variables are allowed in Visualization titles, labels, and notes, as well as Incident Priority reasons.

In Data Ocean Nodes

Structured custom variables can be used as filters in Data Ocean nodes. The structured variable type (e.g., Application) defines what is available in the variable, and, consequently, where it can be used for filtering (e.g. Application filter).

In HTTP Request Nodes

You can use custom variables in HTTP Request nodes to pass data to external applications. For example, you can use a custom variable to send data to an ITSM tool like ServiceNow or to pass information from a Slack message.

In Subflow Nodes

The subflow node will never fail. If the nodes in the subflow fail, the subflow will return an empty output.

You can detect if the subflow succeeded by using a variable that is set in the subflow in a node after the operation you care about. After the subflow completes, you can check the value of the variable to decide how to proceed.