Type to search.

Loop break

Serverless

Elastic Cloud Serverless projects are autoscaled environments, fully managed by Elastic and available on Elastic Cloud.

Availability

  • Generally available

    This functionality is generally available and ready for production usage.

Serverless interfaces and procedures might differ from classic Elastic Stack deployments.

Stack 9.4+

The Elastic Stack includes Elastic's core products such as Elasticsearch, Kibana, Logstash, and Beats.

Availability

  • Generally available since 9.4

    This functionality is generally available and ready for production usage.

Unless stated otherwise on the page, this functionality is available when your Elastic Stack is deployed on Elastic Cloud Hosted, Elastic Cloud Enterprise, Elastic Cloud on Kubernetes, and self-managed environments.

This documentation corresponds to the latest patch available for each minor version. If you're not using the latest patch, check the release notes for changes.

The loop.break step exits the innermost enclosing foreach or while loop immediately. Use it to stop iterating once a condition is met, for example when you want to process items until you find the first critical match and then move on.

Schema convention. In each schema table on this page, the Location column indicates where each parameter sits in the YAML:

  • top level: Alongside type and name, at the top of the step or trigger definition.
  • `with`: Inside the step's with: block.
  • `on`: Inside the trigger's on: block.

The loop.break step takes no step-specific parameters; only the standard name and type fields required on every step.

Parameter Location Type Required Description
name top level string Yes Unique step identifier.
type top level string Yes Must be loop.break.
YAML
- name: find_critical
  type: foreach
  foreach: "${{ event.alerts }}"
  steps:
    - name: check_critical
      type: if
      condition: "foreach.item.kibana.alert.severity : critical"
      steps:
        - name: record_and_exit
          type: cases.addComment
          with:
            case_id: "{{ consts.triage_case_id }}"
            comment: "First critical alert found at position {{ foreach.index }}"
        - name: exit
          type: loop.break

The loop terminates as soon as the first critical alert is processed.