| 1 |
plugin to use MongoDB as backend. |
| 2 |
|
| 3 |
tested in ubuntu 10.04, ubuntu 10.10 and FreeBSD 11.1 |
| 4 |
|
| 5 |
configuration: |
| 6 |
|
| 7 |
in your /etc/rsyslog.conf, together with other modules: |
| 8 |
$ModLoad ommongodb # provides mongodb support |
| 9 |
*.* action(type="ommongodb" db="..." collection="..." template="...") |
| 10 |
|
| 11 |
Note: if no template is specified, a default schema will be used. That schema |
| 12 |
contains proper data types. However, if a template is specified, only strings |
| 13 |
are supported. This is a restriction of the rsyslog v6 core engine. This |
| 14 |
changed in v7. |
| 15 |
|
| 16 |
If templates are used, it is suggested to use list-based templates. Constants |
| 17 |
can ONLY be inserted with list-based templates, as only these provide the |
| 18 |
capability to specify a field name (outname parameter). |
| 19 |
|
| 20 |
A very basic example is: |
| 21 |
|
| 22 |
*.* action(type="ommongodb" db="logs" collection="syslog") |
| 23 |
|
| 24 |
A more complex example: |
| 25 |
*.* action(type="ommongodb" uristr="mongodb://vulture:9091,vulture2:9091/?replicaset=Vulture&ssl=true" ssl_cert="/var/db/mongodb/mongod.pem" ssl_ca="/var/db/mongodb/ca.pem" db="logs" collection="syslog" allowed_error_codes="11000") |
| 26 |
|
| 27 |
Please see the script clean-mongo-syslog for an example of how to |
| 28 |
purge old records from MongoDB using PyMongo. It can be run |
| 29 |
daily or weekly from cron. |
| 30 |
|
| 31 |
You may also wish to index some or all of the columns in MongoDB. |
| 32 |
The following statements may help to create the indexes: |
| 33 |
|
| 34 |
To see the existing indexes: |
| 35 |
|
| 36 |
db.syslog.getIndexes() |
| 37 |
|
| 38 |
To create them: |
| 39 |
|
| 40 |
db.syslog.ensureIndex( { sys : 1 } ) |
| 41 |
db.syslog.ensureIndex( { time : 1 } ) |
| 42 |
db.syslog.ensureIndex( { syslog_fac : 1 } ) |
| 43 |
db.syslog.ensureIndex( { syslog_sever : 1 } ) |
| 44 |
db.syslog.ensureIndex( { syslog_tag : 1 } ) |
| 45 |
db.syslog.ensureIndex( { procid : 1 } ) |
| 46 |
db.syslog.ensureIndex( { pid : 1 } ) |
| 47 |
|
| 48 |
|