The out_mongo_replset Output plugin writes records into MongoDB, the emerging document-oriented database system.
This plugin is for users using ReplicaSet. If you are not using ReplicaSet, please see the out_mongo article instead.
This plugin has breaking changes since 0.8.0 due to mongo-ruby driver's breaking changes. If you are using a prior 0.7.x series, please be careful to upgrade 1.0.0 or later versions.
Why Fluentd with MongoDB?
Fluentd enables your apps to insert records to MongoDB asynchronously with batch-insertion, unlike direct insertion of records from your apps. This has the following advantages:
less impact on application performance
higher MongoDB insertion throughput while maintaining JSON record structure
Install
out_mongo_replset is not included in fluent-package, by default. Fluentd gem users will need to install the fluent-plugin-mongo gem using the following command:
# Single MongoDB
<match mongo.**>
@type mongo_replset
database fluentd
collection test
nodes localhost:27017,localhost:27018,localhost:27019
# The name of the replica set
replica_set myapp
<buffer>
# flush
flush_interval 10s
</buffer>
</match>
<match mongo.*>
@type mongo_replset
database fluentd
nodes localhost:27017,localhost:27018,localhost:27019
# Set 'tag_mapped' if you want to use tag mapped mode.
tag_mapped
# If the tag is "mongo.foo", then the prefix "mongo." is removed.
# The inserted collection name is "foo".
remove_tag_prefix mongo.
# This configuration is used if the tag is not found. The default is 'untagged'.
collection misc
</match>