# switch

> For the complete documentation index, see [llms.txt](https://docs.redpanda.com/llms.txt). Component-specific: [cloud-data-platform-full.txt](https://docs.redpanda.com/cloud-data-platform-full.txt)

---
title: switch
latest-operator-version: v26.1.4
latest-console-tag: v3.7.3
latest-connect-version: 4.93.0
latest-redpanda-tag: v26.1.9
docname: connect/components/processors/switch
page-component-name: cloud-data-platform
page-version: master
page-component-version: master
page-component-title: Cloud
page-relative-src-path: connect/components/processors/switch.adoc
page-edit-url: https://github.com/redpanda-data/cloud-docs/edit/main/modules/develop/pages/connect/components/processors/switch.adoc
page-git-created-date: "2024-09-09"
page-git-modified-date: "2026-05-26"
---

<!-- Source: https://docs.redpanda.com/cloud-data-platform/develop/connect/components/processors/switch.md -->

**Type:** Processor ▼

[Processor](https://docs.redpanda.com/cloud-data-platform/develop/connect/components/processors/switch/)[Output](https://docs.redpanda.com/cloud-data-platform/develop/connect/components/outputs/switch/)[Scanner](https://docs.redpanda.com/cloud-data-platform/develop/connect/components/scanners/switch/)

**Available in:** Cloud, [Self-Managed](https://docs.redpanda.com/connect/components/processors/switch/%20%22View%20the%20Self-Managed%20version%20of%20this%20component%22)

Conditionally processes messages based on their contents.

```yml
# Config fields, showing default values
label: ""
switch: [] # No default (required)
```

For each switch case a [Bloblang query](https://docs.redpanda.com/cloud-data-platform/develop/connect/guides/bloblang/about/) is checked and, if the result is true (or the check is empty) the child processors are executed on the message.

## [](#fields)Fields

### [](#check)`check`

A [Bloblang query](https://docs.redpanda.com/cloud-data-platform/develop/connect/guides/bloblang/about/) that should return a boolean value indicating whether a message should have the processors of this case executed on it. If left empty the case always passes. If the check mapping throws an error the message will be flagged [as having failed](https://docs.redpanda.com/cloud-data-platform/develop/connect/configuration/error_handling/) and will not be tested against any other cases.

**Type**: `string`

**Default**: `""`

```yaml
# Examples:
check: this.type == "foo"

# ---

check: this.contents.urls.contains("https://benthos.dev/")
```

### [](#continue)`continue`

Indicates whether, if this case passes for a message, the next case should also be tested. Unlike `fallthrough`, which skips the next case’s check, `continue` will evaluate the next case’s condition before executing.

**Type**: `bool`

**Default**: `false`

### [](#fallthrough)`fallthrough`

Indicates whether, if this case passes for a message, the next case should also be executed without checking its condition.

**Type**: `bool`

**Default**: `false`

### [](#processors)`processors[]`

A list of [processors](https://docs.redpanda.com/cloud-data-platform/develop/connect/components/processors/about/) to execute on a message.

**Type**: `processor`

**Default**: `[]`

## [](#examples)Examples

### [](#ignore-george)Ignore George

We have a system where we’re counting a metric for all messages that pass through our system. However, occasionally we get messages from George that we don’t care about.

For George’s messages we want to instead emit a metric that gauges how angry he is about being ignored and then we drop it.

```yaml
pipeline:
  processors:
    - switch:
        - check: this.user.name.first != "George"
          processors:
            - metric:
                type: counter
                name: MessagesWeCareAbout

        - processors:
            - metric:
                type: gauge
                name: GeorgesAnger
                value: ${! json("user.anger") }
            - mapping: root = deleted()
```

## [](#batching)Batching

When a switch processor executes on a [batch of messages](https://docs.redpanda.com/cloud-data-platform/develop/connect/configuration/batching/) they are checked individually and can be matched independently against cases. During processing the messages matched against a case are processed as a batch, although the ordering of messages during case processing cannot be guaranteed to match the order as received.

At the end of switch processing the resulting batch will follow the same ordering as the batch was received. If any child processors have split or otherwise grouped messages this grouping will be lost as the result of a switch is always a single batch. In order to perform conditional grouping and/or splitting use the [`group_by` processor](https://docs.redpanda.com/cloud-data-platform/develop/connect/components/processors/group_by/).