Configure the Azure Cosmos DB data source
This document explains how to configure the Azure Cosmos DB data source.
To install the plugin, refer to Install the Azure Cosmos DB data source.
Before you begin
Before you configure the data source, ensure you have:
- License: A Grafana Cloud Pro or Advanced plan, or a self-managed Grafana Enterprise license that includes the plugin. The Azure Cosmos DB data source is an Enterprise plugin and isn’t included in the Grafana Cloud Free plan.
- Grafana permissions: Only users with the organization administrator role can add data sources.
- Installed plugin: The Azure Cosmos DB plugin. Refer to Install the Azure Cosmos DB data source.
- Azure Cosmos DB account: An Azure Cosmos DB for NoSQL account.
- Credentials: Your account endpoint and account key. To find them, refer to Secure access to data in Azure Cosmos DB.
Key concepts
If you’re new to Azure Cosmos DB, these terms are used throughout the configuration:
Add the data source
To add the Azure Cosmos DB data source:
- Click Connections in the left-side menu.
- Click Add new connection.
- Type
Azure Cosmos DBin the search bar. - Select Azure Cosmos DB.
- Click Add new data source.
Configure settings
Configure the following account settings:
Authentication
The Azure Cosmos DB data source authenticates with an account endpoint and an account key. This is currently the only supported authentication method.
To authenticate the data source:
- In Account Endpoint, enter your Azure Cosmos DB account URI.
- In Account Key, enter your primary or secondary account key.
- Click Save & test.
Private data source connect (PDC)
Private data source connect (PDC) lets Grafana Cloud query an Azure Cosmos DB account that’s only reachable from a private network, such as an Azure virtual network or an on-premises environment, without exposing it to the public internet. Because the Azure Cosmos DB data source runs queries in the backend, it supports PDC.
To use PDC with the data source:
- Set up a PDC connection for your Grafana Cloud stack. Refer to Configure Private data source connect (PDC).
- On the Azure Cosmos DB data source configuration page, select your PDC connection from the Private data source connect list.
- Click Save & test.
For more information, refer to Private data source connect (PDC).
Note
On self-managed Grafana, you can route the connection through a secure socks proxy instead. Enable the Secure Socks Proxy option on the data source configuration page, then refer to Configure a data source connection proxy.
Verify the connection
Click Save & test to verify the configuration. When the connection succeeds, Grafana displays a Data source is working message.
If the test fails, refer to Troubleshoot the Azure Cosmos DB data source.
Provision the data source
You can define and configure the data source in YAML files as part of the Grafana provisioning system. Only users with the organization administrator role can add data sources. For more information about provisioning and available settings, refer to Provision Grafana.
Provision with YAML
The following example provisions the data source using an account endpoint and account key:
apiVersion: 1
datasources:
- name: Azure Cosmos DB
type: grafana-azurecosmosdb-datasource
jsonData:
accountEndpoint: <ACCOUNT_ENDPOINT>
secureJsonData:
accountKey: <ACCOUNT_KEY>Replace <ACCOUNT_ENDPOINT> with your account URI and <ACCOUNT_KEY> with your primary or secondary account key.
Provision with Terraform
You can provision the data source with the Grafana Terraform provider using the grafana_data_source resource:
resource "grafana_data_source" "azure_cosmosdb" {
type = "grafana-azurecosmosdb-datasource"
name = "Azure Cosmos DB"
json_data_encoded = jsonencode({
accountEndpoint = "<ACCOUNT_ENDPOINT>"
})
secure_json_data_encoded = jsonencode({
accountKey = "<ACCOUNT_KEY>"
})
}Replace <ACCOUNT_ENDPOINT> with your account URI and <ACCOUNT_KEY> with your primary or secondary account key. Store the account key in a Terraform variable or secret manager rather than in plain text.


