Workflow Logic

Cette page n'est pas encore disponible en français, sa traduction est en cours.
Si vous avez des questions ou des retours sur notre projet de traduction actuel, n'hésitez pas à nous contacter.

Workflow Automation is not supported for your selected Datadog site ().

Use Logic actions to add control logic to your workflow. For example, you can branch from a condition, perform an action iteratively, include a sleep interval, and more.

Branch workflow from condition

You can branch the execution path of your workflow based on the evaluation of one or more statements that you define. In the screenshot below, a Branch workflow from condition action determines the next step in the workflow based on whether the status code of a previous HTTP request action returns 200.

The workflow canvas with a branch workflow from condition action selected and the configuration tab open. The Statements section is highlighted with two statements specifying that the status of a previous request must be 200.

Sleep

The Sleep action pauses the execution of the workflow for a specified duration. Select a predefined duration from the Duration drop-down, or enter a custom variable in seconds.

For loop

The For loop action allows you to execute a set of actions iteratively for each item in a given input list. For loops accept an input list of up to 2000 items. You can perform many different operations within a for loop, including configuring error paths for individual iterations that fail.

In the example below, a for loop iterates over a list of incidents and sends a Slack message for any incident that is more than a week old.

A workflow with a for loop. The loop iterates over a list of incidents and sends a message to a slack channel if the incident is more than a week old.

To add a for loop to your workflow:

  1. Click the plus (+) icon on your workflow canvas to open the action catalog.
  2. Search for and select the For loop step.
  3. Click the loop step and enter an Input list for the step to iterate over. You can enter a custom list or use a workflow variable.
  4. Inside the loop frame, click the (+) icon to add a step to the loop.
  5. Configure the looped action. To access the current value in the input list, use the {{Current.Value}} variable. To access the index of the current value, use {{Current.Index}}.
  6. Add and configure any additional steps you need to loop.
  7. Save and Publish the workflow.

When a run completes, the workflow enters Debug mode. Select a step within the loop to see a list of All, Failed, or Successful iterations for that step. Select an iteration to see the output or the error message.

Further Reading

Documentation, liens et articles supplémentaires utiles:


Do you have questions or feedback? Join the #workflows channel on the Datadog Community Slack.

PREVIEWING: may/unit-testing