# afmongodb \[1]

### Important Information

The syslog-ng OSE mongodb() driver is compatible with MongoDB server version 1.4 and newer. Using mongo() without any parameters uses the following default values:

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

### Status

| Architecture | Status |
| :----------: | :----: |
|      x86     |  Works |
|      ARM     |  Works |

### Testing

From the default values, we can see that mongodb() driver sends the messages to a database named syslog, so to test this driver we first need to set up mongodb to receive these messages. \
\
To do so,

* Install MongoDB
* Create a database called syslog by entering the command:
  * `mongosh syslog`
* Set up the database like so:
  * `db.createCollection( "messages", { capped: true, size: 100000000 } )`
* Once the messages have been transmitted, to view us:
  * `db.messages.find().pretty()`

#### Configuration file used

```
@version: 3.31
@include "scl.conf"

source custom
{
    example-msg-generator(
        num(50)
        freq(2)
        template("Random Message")
    );
};

destination d_mongodb {
    mongodb();
};

log {
    source(custom);
    destination(d_mongodb);
};
```

#### Proof

![Testing mongodb() driver on macOS (x86)](https://3267548193-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MaZdBoDvCx_0JwOUICk%2F-Mcew9kDnhT-Pmtd81Q-%2F-McezmGy-29CBK9eIce7%2FScreenshot%202021-06-20%20at%2010.56.21%20PM.png?alt=media\&token=102a98d7-03d4-464b-9e27-229a06b59333)

![Testing mongodb() driver on macOS (ARM)](https://3267548193-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MaZdBoDvCx_0JwOUICk%2F-MhdPkZ1tvxJKG7y5kc5%2F-MhdTcUbJRW4c5ri04h6%2FScreen%20Shot%202021-08-21%20at%207.10.16%20PM.png?alt=media\&token=0e01aa37-91ec-4796-9376-9169f02a3005)
