Getting Started with Workflow Automation

Overview

With Workflow Automation, you can automate end-to-end processes in response to Datadog alerts and security signals. Workflow Automation is powered by real-time observability data, enabling you to resolve issues faster and proactively maintain the availability and security of your systems.

Follow this guide to create a custom workflow triggered by a monitor alert. When it is triggered, the workflow creates a task in Jira and sends a notification to Slack with a link to the Jira ticket. This guide covers passing data from one step in your workflow to another step, saving and publishing your workflow, and viewing the workflow’s run history.

Prerequisites

Before getting started, you need the Jira and Slack integrations installed on your Datadog account. For installation instructions, see the Slack and Jira integration documentation.

Account credentials and authentication that you set up in the Jira and Slack integration tiles automatically propagate to the Jira and Slack actions in Workflow Automation. Some integrations require additional configuration for authentication. For more information, see Connections.

Build the workflow

Create a workflow with a monitor trigger

You can trigger a workflow from an alert, such as a monitor or security signal, from a schedule, or manually. In this case, create a workflow with a monitor trigger.

Create a workflow:

  1. From the Workflow Automation page, click New Workflow.
  2. Enter a name and description for the workflow. The example workflow uses the following name and description:
    Name: Create a Jira Ticket.
    Description: Create a Jira issue and Slack notification when there is a monitor alert.

Add and configure the monitor:

  1. On the workflow canvas, click Add Trigger and select Monitor.
  2. In the Configure tab, next to @workflow-, enter a unique ID for your workflow: Create-Jira-Ticket.
    Workflow handles always begin with @workflow-. Later, you use this handle to connect the workflow to a monitor notification.
  3. Click Save to save your workflow.
Trigger for Workflows

Add the Jira and Slack actions

Add and configure the Jira step:

  1. On the workflow canvas, click the + icon.

  2. Search for the Jira action and select Create issue.

  3. On the workflow canvas, click the Create issue step.

  4. In the Configure tab, select a Jira Account. The account should correspond to the Jira URL found in the Accounts section of the Jira integration tile.

  5. Enter the Project and Issue type for the Jira issue that the workflow creates.

  6. Enter a Summary and Description for the Jira issue, using context variables to pass in data from the monitor that triggers the workflow. You can access a context variable in a step by enclosing it in double braces ({{).

    The following example description uses the source, trigger, and workflow variables to pass along:

    • the source that triggered the monitor alert
    • a link to the affected monitor
    • the workflow name, and the workflow ID
    The CPU usage is above the 95% threshold for {{ Trigger.hostname }}
    
    Please investigate - see this Datadog Dashboard to view all workflow executions:
    https://app.datadoghq.com/dash/integration/workflow_automation?refresh_mode=sliding&from_ts=1698164453793&to_ts=1698168053793&live=true.
    
    The workflow that created this Jira issue is
    {{ WorkflowName }} : {{ WorkflowId }}
    
    The monitor that triggered the workflow can be found here: {{ Source.url }}
    

    For more information on context variables, see Context variables.

  7. Test the Jira action by clicking Test in the Configure tab. Testing the action creates a real Jira ticket.

  8. Click Save to save your workflow.

Next, add the Slack step:

  1. Click the plus icon on the workflow canvas to add another step.

  2. Search for Slack and select Send message.

  3. Enter the Slack Workspace name.

  4. Enter the Slack Channel name.

  5. For a more useful Slack notification, use step output variables. Step output variables allow you to pass data from the Jira step to the Slack step in your workflow. Use the following message text to include the Jira issue key, the monitor name, and the Jira issue in the Slack message:

    The monitor named {{ Source.monitor.name }} triggered and created a new Jira issue
    {{ Steps.Create_issue.issueKey }}: {{ Steps.Create_issue.issueUrl }}
    
    The workflow that created this Jira issue is {{ WorkflowName }}
    
  6. To test the action, click Test in the Configure tab. Testing an action creates a real Slack message.

  7. To view your workflow’s name in the monitor’s notification dropdown, save and publish your workflow. Click Publish from the workflow’s page.

Test and publish the workflow

Testing a workflow connected to active Slack and Jira accounts creates actual Slack messages and Jira tickets.

Click Save to apply your changes to the workflow. Next, manually trigger the workflow to test it.

To trigger the workflow manually, click Run from the workflow page, and enter the values for the trigger variables.

Trigger a workflow manually

Confirm that running the workflow creates a Jira ticket and sends a Slack message.

Scheduled and triggered workflows don’t trigger automatically until you publish them. To publish the workflow, click Publish from the workflow’s page.

Update the monitor that triggers your workflow

  1. Navigate to the Monitors page in Datadog.
  2. Find the monitor you’d like to use to trigger the workflow and edit it, or create a new monitor.
  3. In the Configure notifications & automations section, click Add Workflow.
  4. Use the workflow mention name (@workflow-Create-Jira-Ticket) to search for your workflow and select it from the drop-down.
    • You can pass trigger variables into the workflow using a comma-separated list with the syntax @workflow-name(key=value, key=value). For example, @workflow-Create-Jira-Ticket(hostname={{host.name}}).
  5. Click Test Notifications to test the workflow and all of this monitor’s notifications.
  6. Save the monitor.
Trigger a workflow from a Monitor

Each time the monitor threshold is hit, the monitor triggers a workflow run.

Run history

After you trigger the workflow, you can watch its progress and debug failed steps in the Run History view. Select an executed step to see the inputs, outputs, execution context, and error messages. The example below shows a step that failed due to an invalid Jira configuration.

To make edits to your workflow, click Configuration. To get back to the run history view, click Run History.

To view a list of previous workflow executions and whether each execution succeeded or failed, use the initial run history view. Return to the initial execution history at any time by clicking on the workflow canvas.

Conclusion

When the monitor triggers the workflow, it creates a Jira issue for your engineering team to review. Here is an example Jira issue:

Jira ticket that is generated from the workflow

The workflow also creates a Slack message to notify your team of the Jira issue and monitor alert. Here is an example Slack notification:

Slack message that is generated from the workflow

What’s next?

  • Explore the list of all available workflow actions in the Actions Catalog.
  • Build a workflow from an out of the box blueprint.
  • Use the HTTP action to make a request to any endpoint.
  • Implement data transformation actions to perform necessary operations on the information flowing through your workflow.

Further reading

PREVIEWING: safchain/fix-custom-agent