DocumentationPluginsMongoDB data sourceConfigure the MongoDB data source

Configure the MongoDB data source

To install a data source, refer to Install Grafana plugins. For general information on adding a data source see Add a 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:

  1. Click Connections in the left-side menu.
  2. Under Connections, click Add new connection.
  3. Enter MongoDB in the search bar.
  4. Select MongoDB under the Data Source section.
  5. 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.

Configuration options

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: mongodb://myDatabaseUserName:StrongP%ssw0rd@localhost/sales_db; mongodb://myDatabaseUserName:StrongP%ssw0rd@%2Ftmp%2Fmongodb-27017.sock


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 Server name, Client certificate and 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.

  • Kerberos - See Kerberos Authentication

Additional settings

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.

Kerberos Authentication

  • Kerberos requires a custom build with manual installation. The custom build can be found here.

  • When running on Linux, the libkrb5 library is required: apt-get install -y libkrb5-dev

  • Use the Credentials Authentication option.

  • Connection String - Append the parameter authMechanism=GSSAPI. For example: mongodb://localhost:27017/?authMechanism=GSSAPI

  • User - the Kerberos principal

  • Password - no password is required when using Kerberos