Skip to main content

Workflows

Overview

The Workflows tool in Cortex allow you to automate running sequential actions and development workflows based on contextual data that exist inside your workspace. This tool supports both simple workflows, like granting permissions to a database, and sophisticated ones, like creating a Jira ticket for an incident detected in Cortex.

View workflows and run history

To see your workflows, click Workflows in the lefthand navigation menu.

Click Workflows on the left sidebar

In the Workflows tab, view all existing workflows, including each workflow's name, description, and last update. If a workflow is in draft mode, you'll also see a Draft tag next to its name. From this page, you can edit, run, delete, or create a workflow.

In the Runs tab, view historic runs for each workflow, as well as each run's status: In Progress, Paused, Successful, Canceled, or Error.

View workflow run history in the Runs tab

Creating a workflow

note

Your Cortex user must have the Edit Workflows permission in order to complete these steps.

You can choose to create a workflow from a template or you can choose to create one from scratch.

There are templates available for the following common workflows:

  • Create AWS S3 bucket
  • Create AWS EC2 instance
  • Create ServiceNow incident
  • Create Azure function
  • Create Jira issue

Step 1: Choose a template or a blank workflow

  1. In the lefthand navigation menu of Cortex, click Workflows.
  2. On the right side of the search bar, click Create workflow. Create Workflows link on right side of search bar
  3. Choose whether to start with a template or start from scratch. tile options to start with a template or start from scratch
    • Workflow Template: Click the tile for the template you wish to use, then click Continue at the bottom of the page.
      • Note: Each tile displays the requirements for secrets you must define before using the template; make sure to follow the template's requirements before you proceed.
    • Start from Scratch: Click Start from Scratch, then click Continue at the bottom of the page.

Step 2: Configure your workflow settings

  1. On the Create Workflow page, fill in the fields to configure your workflow. The name, slug, and description are prepopulated for templates.
    • Name: Enter a descriptive name for your workflow.
    • Slug: Enter a unique slug. If you have previously used a template, make sure to update the prepopulated slug when you use the template again.
    • Scope: Select Entity to narrow the workflow's scope to a specific entity, or select Global if the workflow should not be scoped to a specific entity.
      • When you choose Entity, you must select an Entity Type. Optionally, you can also choose groups to include or exclude.
    • Permission: Select which users are able to view and run this workflow.
      • All: All users in your workspace can access the workflow.
      • Workflows write: Only users with the permission to "Edit Workflows" can view and run the workflow.
        Configure the workflow settings
  2. Optionally, if you want to first save this workflow as a draft, toggle the Draft setting on.
    • When a workflow is saved as a draft, it is only visible to users with the Workflow Write permission.
  3. Click Save Workflow.

Step 3: Add actions to your workflow

To add an action to your workflow, click + in the workflow visual in the center of the page.

Click + to add an action

You can create the following action types:

  • Branch
  • Data transformation
  • HTTP request
  • Manual approval
  • Scaffolder
  • Slack
  • User input

Action types

caution

The slug for each action must be unique across a workflow.

See the tabs below for instructions specific to each type of action that you can add to a workflow.

The Branch action allows you to set up to five conditional paths for a workflow.

The Branch tile is highlighted

To configure a branch action:

  1. Click Branch from the list of actions.
  2. Enter a name.
    • The slug field will automatically pre-populate based on the name you enter.
  3. Click +Add Path.
  4. In the dialog that appears, enter a name, a slug, and a path expression.
    • The path expression is compatible with CEL syntax. The path expression does not accept dashed values; if you reference an action's slug that contains a dash, wrap the slug in quotes and square brackets.
      • For example, if you want to reference an action with the slug example-action, the expression would begin with actions["example-action"].
        Fill out the path creation fields
tip

Autocomplete will provide correctly formatted options based on the actions defined in your workflow.

  1. Click Add path.
    • You will be redirected to the action editor page, showing your newly-added path in the workflow visual.
  2. Optionally, add additional paths and a fallback path.
  3. When you are finished adding paths, click Save Action at the bottom of the action editor.

Click + under a path to add the next type of action. You can add any action type, including another branch.

How paths work

The paths defined run sequentially. The first path that returns true will execute, even if subsequent paths would also return true. The workflow will then continue performing actions in that path. You can also set a fallback path that will run if all other paths fail.

Primary and nested branches function the same way.

Nested branches

You can nest a branch under any or all of the original paths, but you cannot nest further.

To nest a branch:

  1. In the visual workflow, click the + that is branched off your original branch. Click the + off the original branch
  2. On the right side of the page in the workflow editor, select Branch.
  3. Enter a name for your branch, then click Save action.
    A visual of a nested branch and path

In the example screen shot above, you could add another branch action under Path 2 on the right, but you cannot add another under branch action under the nested path. You can, however, add other action types under the nested path.


Running a workflow

Run a workflow from the Workflows page

  1. On the Workflows page, locate the workflow you want to run.
  2. On the right side of the workflow, click the Play icon. Click the play icon to run a workflow
    • The workflow will automatically launch. Workflows that require User input or Manual approval will pause until your configured input or approval is completed.

When an action completes, a green checkmark is displayed in the top right corner. Actions that require input or approval will display an orange Pause icon.

Completed actions show a green checkmark, paused actions show an orange pause icon

When a run has been started, it appears in the Runs tab on the Workflows page. A completed runs will display as Successful, while those awaiting input or approval will display as Paused.

Run a workflow from an Entity

You can also run a workflow while viewing an Entity:

  1. On the left navigation menu of Cortex, click Catalogs > All Entities.
  2. Click an entity to view its details page.
  3. On the left side of the entity details, click Workflows to view and run any entity-scoped workflows. The Workflows link is on the left side of an entity page

Cancel a workflow

If you cancel a run that is partially complete, it will not undo any successfully completed actions.

To cancel a running workflow:

  1. On the Workflows page, click the Runs tab then locate the workflow you want to cancel.
  2. Click on the workflow to view its run details page.
  3. Click Cancel run.

In the upper right click Cancel Run

View an action's inputs, outputs, and run context

After you run a workflow, navigate to the run details page. Select any of its individual actions to view the action's Inputs, Outputs, and Run context in the side panel.

View a run's inputs, output, and context