mongodb(): Store messages in a MongoDB database

The mongodb() driver sends messages to a MongoDB database. MongoDB is a schema-free, document-oriented database. For the list of available optional parameters, see mongodb() destination options.

Declaration

   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.

Example: Using the mongodb() driver

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

   destination d_mongodb {
        mongodb();
    };

The following example displays the default values.

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

The following example shows the same setup using the deprecated libmongo-client syntax (as used in AxoSyslog version 3.7), and is equivalent with the previous example.

   destination d_mongodb {
        mongodb(
            servers("localhost:27017")
            database("syslog")
            collection("messages")
            value-pairs(
                scope("selected-macros" "nv-pairs" "sdata")
            )
        );
    };
Last modified October 29, 2023: Create manpages (#34) (9534f54)