Configure a JDBC connection to MongoDB Standalone using Splunk JDBC Driver for MongoDB

Authentication

It supports a basic authentication method using user and password attributes passed as a property or as a part of the connection string as query parameters. It requires to provide the authSource value as the database name associated with the user's credentials.

JDBC connection string

Using this driver the JDBC connection string should start with the prefix jdbc:standalone-mongodb:// followed by the IP address / FQDN, port and database name, such as jdbc:standalone-mongodb://<host>:<port>/<database>.<collection>?authSource=<user-credentials-database>.

Note: the <collection> attribute is optional.

SSL connection

To use SSL connection specify ssl=true as part of the connection string as a query parameter.

Driver class

It supports auto loading according to JDBC 4.0, but in case there is a need for register it manually the driver class is com.splunk.dbx.mongodb.standalone.StandaloneDriver.

Queries

This driver supports find and aggregate statements similar to MongoDB Shell.

When querying a collection and the database name or collection name contains periods (.), you must enclose the database and collection in square brackets as follows:

[arts].[movies.usa].aggregate([{$match: {}}])

Where arts is the name of the database and movies.usa is the name of the collection. Note that both are enclosed in square brackets, even if only the collection name contains periods (.).

Find Method

{ <attribute>: { $gt: <value> } }: it will execute a find method for the database and collection defined in the JDBC Connection String.

In case we don't specify the collection in the JDBC Connection String, or we want overwrite it, we do it as follows: <database>.<collection>.find({ <attribute>: { $gt: <value> } }).

Note: For more information, go to db.collection.find. Please, note that we don't support projection and options yet.

Aggregate Method

[{ $match: { <attribute>: { $gt: <value> } } }, { $sort: { <attribute>: 1} }]: it will execute an aggregate method for the database and collection defined in the JDBC Connection String.

In case we don't specify the collection in the JDBC Connection String, or we want overwrite it, we do it as follows: <database>.<collection>.aggregate([{ $match: { <attribute>: { $gt: <value> } } }, { $sort: { <attribute>: 1} }]).

Note: For more information, go to db.collection.aggregate. Please, note that we don't support options yet.