Subflow Creation Example

This walkthrough builds a reusable subflowClosed A reusable automation chunk that performs frequently used functions, such as opening a ticket in an external system, and can be used to implement integrations with third-party systems. that resolves an applicationClosed An entity type representing software applications deployed in the customer environment that are monitored for performance and anomalies. name, then calls that subflow from an incident 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.. For concepts and general procedures, see Working with Subflows.

The Subflow Editor is a pared-down Runbook Editor. It does not include triggerClosed A set of one or more indicators that have been correlated based on certain relationships, such as time, metric type, application affected, location, or network device. nodes, Impact Statement nodes, or visualizationClosed A runbook node category that shows data in a chart, graph, table, or note, providing visual representation of analysis results in runbook output. nodes. Every subflow begins with a Subflow Input node (added automatically) and ends with at least one Subflow Output node.

Note: You cannot create a subflow while editing a runbook. Create the subflow first, then add it to the runbook.

Scenario

Imagine an incident runbook that queries application data and shows the application name in a table. The middle of that flow (query and shape the application name) is worth reusing. This example defines that middle section as a subflow, then wires the subflow into a parent runbook.

Create the subflow

  1. Navigate to the Subflows page:

    1. Click Automation in the left menu.

    2. Click Subflows.

  2. Click New to open the Subflow Editor. Note the Subflow Input node on the canvas.

  3. Click Variables in the toolbar to open the Variable Definition Editor. Create two Subflow scope String variables named appNameIn and appNameOut. Click Add Subflow Variable, choose String, add both variables, then click Save & Close.

  4. Select the Subflow Input node. Under Starting Entity, set the input data properties name to Application. Under Context Values Received From Caller, add subflow.appNameIn. Under Context Values Sent Back To Caller, add subflow.appNameOut. Click Save & Close.

  5. Add a Set Primitive Variable node after the Subflow Input node. Set the variable to subflow.appNameOut. In the template, set the value from the application field on the node input, for example:

    Copy
    {
      "subflow.appNameOut": "{{node_input.output.data[0].keys['application.name']}}"
    }

    Click Save & Close.

  6. Add a Decision Branch node with one conditioned output and one default output.

  7. For the conditioned output, add a Variable condition that treats an empty subflow.appNameIn as a match (for example, regex ^$). Add a default output for every other case. Click Save & Close.

  8. On the conditioned branch, add an Application data query node. In Filters, choose applications from the subflow input. Enable Collect Metrics and add Throughput, Traffic, and Packets. Click Save & Close.

  9. On the default branch, add a Transform node. Keep Manual output data definition, set the output data properties to Application, and use a transform template that builds an application object from subflow.appNameIn. Click Save & Close.

  10. After the Transform node, add another Application data query that filters by applications from the closest parent (the Transform node), with the same metrics as before. Click Save & Close.

  11. Add a Subflow Output node at the end of each branch. Two outputs are valid when the branches are mutually exclusive.

    Subflow canvas with Decision Branch, Application data query, Transform, and Subflow Output nodes

  12. Save the subflow.

Call the subflow from a runbook

  1. Open the Runbooks page and click New to open the Runbook Editor.

  2. Open the Variable Definition Editor and create a Runtime scope String variable named appName.

  3. Add an Application trigger node.

  4. From the Subflows category in the Node palette, drag the subflow you created onto the canvas after the trigger.

  5. Select the subflow node. On the Input tab, set the incoming application name variable (for example to x11). On the Output tab, map appNameOut to runtime.appName (or the runtime variable name you created). Click Save & Close.

  6. Optionally add a second instance of the same subflow from the trigger without setting the input variable, so you can compare explicit versus inherited context.

  7. Add a Table visualization after each subflow instance.

    Runbook canvas with Application trigger, two subflow instances, and Table visualizations

  8. Click Execute a Test Run, supply an application when prompted, and confirm the table output. When you set the input explicitly (for example to x11), that value appears in the corresponding table.

For more use-case ideas, see Subflow Use Case Examples.