mongodb: Storing 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 syslog-ng OSE, use the key() parameter of the value-pairs() option.
The syslog-ng OSE mongodb() driver is compatible with MongoDB server version 1.4 and newer.
NOTE: By default, syslog-ng OSE handles every message field as a string. For details on how to send selected fields as other types of data (for example, handle the PID as a number), see Specifying data types in value-pairs.
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 syslog-ng OSE version
destination d_mongodb { mongodb( servers("localhost:27017") database("syslog") collection("messages") value-pairs( scope("selected-macros" "nv-pairs" "sdata") ) ); };