Configure the MongoDB data source
Only users with the organization
administrator role can add data sources. Administrators can also configure the data source via YAML with Grafana’s provisioning system.
Configure the data source
To add the MongoDB data source, complete the following steps:
- Click Connections in the left-side menu.
- Under Connections, click Add new connection.
MongoDBin the search bar.
- Select MongoDB under the Data Source section.
- Click Add new data source in the upper right.
You will be taken to the Settings tab where you will set up your MongoDB configuration.
The following is a list configuration options for MongoDB.
The first option to configure is the name of your connection:
Name - The data source name. This is how you refer to the data source in panels and queries. Examples: MongoDB-1, MongoDB_Marketing.
Default - Toggle to select as the default name in dashboard panels. When you go to a dashboard panel this will be the default selected data source.
You connect to MongoDB using a connection string. For more information see Connection Strings.
- Connection string - Insert your MongoDB connection string, which contains the parameters required to connect to MongoDB. Examples:
There are several authentication methods you can choose in the Authentication section.
In the dropdown you can select the following authentication methods:
No authentication - Allows access to the data source without any authentication
Credentials - Authenticate with the default credentials assigned to MongoDB at account creation.
- User - The username assigned to the MongoDB account.
- Password - The password assigned to the MongoDB account.
TLS Settings - Use TLS (Transport Layer Security) for an additional layer of security when working with MongoDB.
Add self-signed certificate - Check the box to authenticate with a CA certificate. Follow the instructions of the CA (Certificate Authority) to download the certificate file. Required for verifying self-signed TLS certificates.
TLS client authentication - Check the box to authenticate with the TLS client, where the server authenticates the client. Add the
Client key. The ServerName is used to verify the hostname on the returned certificate. The Client certificate can be generated from a Certificate Authority (CA) or be self-signed. The Client key can also be generated from a Certificate Authority (CA) or be self-signed. The client key encrypts the data between client and server.
Skip TLS certificate validation - Check the box to bypass TLS certificate validation. Skipping TLS certificate validation is not recommended unless absolutely necessary or for testing purposes.
Additional settings are additional settings for the MongoDB data source and are optional settings that can be configured for more control over the MongoDB data source.
Query syntax validation
- Enable syntax validation - Toggle on to enable real time query syntax validation. MongoDB BSON syntax will be validated as you type and show contextual errors. See Document Data Format: BSON for more information.
Backend response rows limit
- Rows to return - Sets the maximum number of rows returned in a query. The default is
100000. Note that setting this number too high may lead to performance issues with larger queries.
Private data source connect (PDC) and MongoDB
Use private data source connect (PDC) to connect to and query data within a secure network without opening that network to inbound traffic from Grafana Cloud. See Private data source connect for more information on how PDC works and Configure Grafana private data source connect (PDC) for steps on setting up a PDC connection.
- Private data source connect - Click in the box to set the default PDC connection from the dropdown menu or create a new connection.
Once you have configured your MongDB data source options, click Save & test at the bottom to test out your data source connection. You can also remove a connection by clicking Delete.