# mongodb

> 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: mongodb
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/outputs/mongodb
page-component-name: cloud-data-platform
page-version: master
page-component-version: master
page-component-title: Cloud
page-relative-src-path: connect/components/outputs/mongodb.adoc
page-edit-url: https://github.com/redpanda-data/cloud-docs/edit/main/modules/develop/pages/connect/components/outputs/mongodb.adoc
page-git-created-date: "2025-06-25"
page-git-modified-date: "2026-05-26"
---

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

**Type:** Output ▼

[Output](https://docs.redpanda.com/cloud-data-platform/develop/connect/components/outputs/mongodb/)[Cache](https://docs.redpanda.com/cloud-data-platform/develop/connect/components/caches/mongodb/)[Input](https://docs.redpanda.com/cloud-data-platform/develop/connect/components/inputs/mongodb/)[Processor](https://docs.redpanda.com/cloud-data-platform/develop/connect/components/processors/mongodb/)

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

Inserts items into a MongoDB collection.

#### Common

```yml
outputs:
  label: ""
  mongodb:
    url: "" # No default (required)
    database: "" # No default (required)
    username: ""
    password: ""
    collection: "" # No default (required)
    operation: update-one
    write_concern:
      w: majority
      j: false
      w_timeout: ""
    document_map: ""
    filter_map: ""
    hint_map: ""
    upsert: false
    max_in_flight: 64
    batching:
      count: 0
      byte_size: 0
      period: ""
      check: ""
      processors: [] # No default (optional)
```

#### Advanced

```yml
outputs:
  label: ""
  mongodb:
    url: "" # No default (required)
    database: "" # No default (required)
    username: ""
    password: ""
    app_name: benthos
    collection: "" # No default (required)
    operation: update-one
    write_concern:
      w: majority
      j: false
      w_timeout: ""
    document_map: ""
    filter_map: ""
    hint_map: ""
    upsert: false
    max_in_flight: 64
    batching:
      count: 0
      byte_size: 0
      period: ""
      check: ""
      processors: [] # No default (optional)
```

## [](#performance)Performance

This output benefits from sending multiple messages in flight, in parallel, for improved performance. You can tune the maximum number of in flight messages (or message batches) using the `max_in_flight` field.

This output benefits from sending messages as a batch for improved performance. Batches can be formed at both the input and output level. For more information, see [Message Batching](https://docs.redpanda.com/cloud-data-platform/develop/connect/configuration/batching/).

## [](#fields)Fields

### [](#app_name)`app_name`

The client application name.

**Type**: `string`

**Default**: `benthos`

### [](#batching)`batching`

Allows you to configure a [batching policy](https://docs.redpanda.com/cloud-data-platform/develop/connect/configuration/batching/).

**Type**: `object`

```yaml
# Examples:
batching:
  byte_size: 5000
  count: 0
  period: 1s

# ---

batching:
  count: 10
  period: 1s

# ---

batching:
  check: this.contains("END BATCH")
  count: 0
  period: 1m
```

### [](#batching-byte_size)`batching.byte_size`

The number of bytes at which the batch is flushed. Set to `0` to disable size-based batching.

**Type**: `int`

**Default**: `0`

### [](#batching-check)`batching.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 end a batch.

**Type**: `string`

**Default**: `""`

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

### [](#batching-count)`batching.count`

The number of messages after which the batch is flushed. Set to `0` to disable count-based batching.

**Type**: `int`

**Default**: `0`

### [](#batching-period)`batching.period`

The period of time after which an incomplete batch is flushed regardless of its size. This field accepts Go duration format strings such as `100ms`, `1s`, or `5s`.

**Type**: `string`

**Default**: `""`

```yaml
# Examples:
period: 1s

# ---

period: 1m

# ---

period: 500ms
```

### [](#batching-processors)`batching.processors[]`

A list of [processors](https://docs.redpanda.com/cloud-data-platform/develop/connect/components/processors/about/) to apply to a batch as it is flushed. This allows you to aggregate and archive the batch however you see fit. All resulting messages are flushed as a single batch, and therefore splitting the batch into smaller batches using these processors is a no-op.

**Type**: `processor`

```yaml
# Examples:
processors:
  - archive:
      format: concatenate

# ---

processors:
  - archive:
      format: lines

# ---

processors:
  - archive:
      format: json_array
```

### [](#collection)`collection`

The name of the target collection. This field supports [interpolation functions](https://docs.redpanda.com/cloud-data-platform/develop/connect/configuration/interpolation/#bloblang-queries).

**Type**: `string`

### [](#database)`database`

The name of the target MongoDB database.

**Type**: `string`

### [](#document_map)`document_map`

A Bloblang map that represents a document to store in MongoDB, expressed as [extended JSON in canonical form](https://www.mongodb.com/docs/manual/reference/mongodb-extended-json/). The `document_map` parameter is required for the following database operations: `insert-one`, `replace-one`, and `update-one`.

**Type**: `string`

**Default**: `""`

```yaml
# Examples:
document_map: |-
  root.a = this.foo
  root.b = this.bar
```

### [](#filter_map)`filter_map`

A Bloblang map that represents a filter for a MongoDB command, expressed as [extended JSON in canonical form](https://www.mongodb.com/docs/manual/reference/mongodb-extended-json/). The `filter_map` parameter is required for all database operations except `insert-one`.

This output uses `filter_map` to find documents for the specified operation. For example, for a `delete-one` operation, the filter map should include the fields required to locate the document for deletion.

**Type**: `string`

**Default**: `""`

```yaml
# Examples:
filter_map: |-
  root.a = this.foo
  root.b = this.bar
```

### [](#hint_map)`hint_map`

A Bloblang map that represents a hint or index for a MongoDB command to use, expressed as [extended JSON in canonical form](https://www.mongodb.com/docs/manual/reference/mongodb-extended-json/). This map is optional, and is used with all operations except `insert-one`.

Define a `hint_map` to improve performance when finding documents in the MongoDB database.

**Type**: `string`

**Default**: `""`

```yaml
# Examples:
hint_map: |-
  root.a = this.foo
  root.b = this.bar
```

### [](#max_in_flight)`max_in_flight`

The maximum number of messages to have in flight at a given time. Increase this number to improve throughput.

**Type**: `int`

**Default**: `64`

### [](#operation)`operation`

The MongoDB database operation to perform.

**Type**: `string`

**Default**: `update-one`

**Options**: `insert-one`, `delete-one`, `delete-many`, `replace-one`, `update-one`

### [](#password)`password`

The password to use for authentication. Used together with `username` for basic authentication or with encrypted private keys for secure access.

> ⚠️ **CAUTION**
>
> This field contains sensitive information that usually shouldn’t be added to a configuration directly. For more information, see [Manage Secrets](https://docs.redpanda.com/cloud-data-platform/develop/connect/configuration/secret-management/) before adding it to your configuration.

**Type**: `string`

**Default**: `""`

### [](#upsert)`upsert`

The `upsert` parameter is optional, and only applies for `update-one` and `replace-one` operations. If the filter specified in `filter_map` matches an existing document, this operation updates or replaces the document, otherwise a new document is created.

**Type**: `bool`

**Default**: `false`

### [](#url)`url`

The URL of the target MongoDB server.

**Type**: `string`

```yaml
# Examples:
url: mongodb://localhost:27017
```

### [](#username)`username`

The username required to connect to the database.

**Type**: `string`

**Default**: `""`

### [](#write_concern)`write_concern`

The [write concern settings](https://www.mongodb.com/docs/manual/reference/write-concern/) for the MongoDB connection.

**Type**: `object`

### [](#write_concern-j)`write_concern.j`

The `j` requests acknowledgement from MongoDB, which is created when write operations are written to the journal.

**Type**: `bool`

**Default**: `false`

### [](#write_concern-w)`write_concern.w`

The `w` requests acknowledgement, which write operations propagate to the specified number of MongoDB instances.

**Type**: `string`

**Default**: `majority`

### [](#write_concern-w_timeout)`write_concern.w_timeout`

The write concern timeout.

**Type**: `string`

**Default**: `""`