---
title: "mongodb(): Store messages in a MongoDB database"
url: "https://axoflow.com/docs/axosyslog-core/4.28/chapter-destinations/configuring-destinations-mongodb/"
last_modified: "2026-10-02T10:40:12+02:00"
---

> For the complete documentation index, see [llms.txt](https://axoflow.com/docs/axosyslog-core/4.28/llms.txt).

# mongodb(): Store messages in a MongoDB database

The `mongodb()` driver sends messages to a [MongoDB](https://www.mongodb.com/) database. MongoDB is a schema-free, document-oriented database. For the list of available optional parameters, see [mongodb() destination options](https://axoflow.com/docs/axosyslog-core/4.28/chapter-destinations/configuring-destinations-mongodb/reference-destination-mongodb/index.md).

## Prerequisites

This feature requires a separate module. Install the `axosyslog-mod-mongodb` package on [Debian/Ubuntu](https://axoflow.com/docs/axosyslog-core/4.28/install/debian-ubuntu/index.md), or the `axosyslog-mongodb` package on [RHEL and compatible distributions](https://axoflow.com/docs/axosyslog-core/4.28/install/rhel-fedora-almalinux/index.md). If the module isn’t installed, AxoSyslog fails to start with an [`unexpected LL_IDENTIFIER` error](https://axoflow.com/docs/axosyslog-core/4.28/chapter-troubleshooting-syslog-ng/unexpected-ll-identifier/index.md).

## Declaration

```shell
   mongodb(parameters);
```

The `mongodb()` driver does not support creating indexes, as that can be a very complex operation in MongoDB. If needed, the administrator of the MongoDB database must ensure that indexes are created on the collections.

The `mongodb()` driver does not add the `_id` field to the message: the MongoDB server will do that automatically, if none is present. If you want to override this field from AxoSyslog, use the `key()` parameter of the `value-pairs()` option.

The AxoSyslog `mongodb()` driver is compatible with MongoDB server version 1.4 and newer.

> **Note:**
>
> Prior to version 4.0, AxoSyslog handled every data as strings, and allowed you to convert the strings into other types of data that only certain destinations data formats supported.
>
> Starting with AxoSyslog 4.0, each name-value pair is a (name, type, value) triplet, and several components of AxoSyslog have typing support. For details, see [Components that support data types](https://axoflow.com/docs/axosyslog-core/4.28/chapter-concepts/concepts-value-pairs/specifying-data-types/index.md#data-types-components).

## Example: Using the mongodb() driver

The following example creates a `mongodb()` destination using only default values.

```shell
   destination d_mongodb {
        mongodb();
    };
```

The following example displays the default values.

```shell
   destination d_mongodb {
        mongodb(
            uri("mongodb://localhost:27017/syslog")
            collection("messages")
            value-pairs(
                scope("selected-macros" "nv-pairs" "sdata")
            )
        );
    };
```

---

[mongodb() destination options](https://axoflow.com/docs/axosyslog-core/4.28/chapter-destinations/configuring-destinations-mongodb/reference-destination-mongodb/index.md)

Last modified October 2, 2026: [Delete obsolete mongodb examples (ef72d65c)](https://github.com/axoflow/axosyslog-core-docs/commit/ef72d65c529dbfd576fb900ace268e22ad0fd4d3)
