Azure Cosmos DB
Azure Cosmos DB is a fully managed NoSQL and relational database for modern app development offering single-digit millisecond response times, automatic and instant scalability, along with guaranteed speed at any scale. This integration helps in monitoring the overall performance, failures, capacity, and operational health of all your Azure Cosmos DB resources.
The below instructions applies to the following database APIs:
- NoSQL
- MongoDB
- Cassandra
- Gremlin
- Table
This app is tested with Azure Cosmos DB for MongoDB, Cassandra, and NoSQL database account types.
Log and metric types​
For Azure Cosmos DB, you can collect the following logs and metrics:
-
Resource logs. To learn more about the different resource log category types and schemas collected for Azure Cosmos DB, refer to the Azure documentation.
-
Platform Metrics for Azure Cosmos DB. For more information on supported metrics and dimensions, refer to the Azure documentation. These metrics are available in the following namespaces:
Microsoft.DocumentDB/applicationGateways
Microsoft.DocumentDB/cassandraClusters
Microsoft.DocumentDB/mongoClusters
-
Activity logs. Provides insight into any subscription-level or management group level events that have occurred in the Azure. To learn more, refer to the Azure documentation.
Setup​
Azure service sends monitoring data to Azure Monitor, which can then stream data to Eventhub. Sumo Logic supports:
- Logs collection from Azure Monitor using our Azure Event Hubs source.
- Metrics collection using our HTTP Logs and Metrics source via Azure Functions deployed using the ARM template.
You must explicitly enable diagnostic settings for each Azure Cosmos DB account you want to monitor. You can forward logs to the same Event Hub provided they satisfy the limitations and permissions as described here.
When you configure the Event Hubs source or HTTP source, plan your source category to ease the querying process. A hierarchical approach allows you to make use of wildcards. For example: Azure/CosmosDB/Logs
, Azure/CosmosDB/Metrics
.
Configure field in field schema​
- Classic UI. In the main Sumo Logic menu, select Manage Data > Logs > Fields.
New UI. In the top menu select Configuration, and then under Logs select Fields. You can also click the Go To... menu at the top of the screen and select Fields. - Search for the following fields:
tenant_name
. This field is tagged at the collector level. You can get the tenant name using the instructions here.location
. The region to which the resource name belongs to.subscription_id
. ID associated with a subscription where the resource is present.resource_group
. The resource group name where the Azure resource is present.provider_name
. Azure resource provider name (for example, Microsoft.Network).resource_type
. Azure resource type (for example, storage accounts).resource_name
. The name of the resource (for example, storage account name).service_type
. Type of the service that can be accessed with a Azure resource.service_name
. Services that can be accessed with an Azure resource (for example, Azure SQL databases in Azure SQL Server).
- Create the fields if they are not present. Refer to Manage fields.
Configure Field Extraction Rules​
Create the following Field Extraction Rules (FER) for Azure Storage by following the instructions in Create a Field Extraction Rule.
Azure location extraction FER​
Rule Name: AzureLocationExtractionFER
Applied at: Ingest Time
Scope (Specific Data): tenant_name=*
json "location", "properties.resourceLocation", "properties.region", "properties.regionname" as location, resourceLocation, service_region, resourceRegion nodrop
| replace(toLowerCase(resourceLocation), " ", "") as resourceLocation
| if (!isBlank(resourceLocation), resourceLocation, location) as location
| if (!isBlank(service_region), service_region, location) as location
| if (!isBlank(resourceRegion), resourceRegion, location) as location
| if (isBlank(location), "global", location) as location
| fields location
Resource ID extraction FER​
Rule Name: AzureResourceIdExtractionFER
Applied at: Ingest Time
Scope (Specific Data): tenant_name=*
json "resourceId", "ResourceId" as resourceId1, resourceId2 nodrop
| if (isBlank(resourceId1), resourceId2, resourceId1) as resourceId
| toUpperCase(resourceId) as resourceId
| parse regex field=resourceId "/SUBSCRIPTIONS/(?<subscription_id>[^/]+)" nodrop
| parse field=resourceId "/RESOURCEGROUPS/*/" as resource_group nodrop
| parse regex field=resourceId "/PROVIDERS/(?<provider_name>[^/]+)" nodrop
| parse regex field=resourceId "/PROVIDERS/[^/]+(?:/LOCATIONS/[^/]+)?/(?<resource_type>[^/]+)/(?<resource_name>.+)" nodrop
| parse regex field=resource_name "(?<parent_resource_name>[^/]+)(?:/PROVIDERS/[^/]+)?/(?<service_type>[^/]+)/?(?<service_name>.+)" nodrop
| if (isBlank(parent_resource_name), resource_name, parent_resource_name) as resource_name
| fields subscription_id, location, provider_name, resource_group, resource_type, resource_name, service_type, service_name
Configure metric rules​
Create the following metrics rules by following the instructions in Create a metrics rule.
Azure observability metadata extraction application gateway level​
Rule Name: AzureObservabilityMetadataExtractionCosmosDBAccountLevel
resourceId=/SUBSCRIPTIONS/*/RESOURCEGROUPS/*/PROVIDERS/MICROSOFT.DOCUMENTDB/*/* tenant_name=*
Fields extracted | Metric rule |
---|---|
subscription_id | $resourceId._1 |
resource_group | $resourceId._2 |
provider_name | MICROSOFT.DOCUMENTDB |
resource_type | $resourceId._3 |
resource_name | $resourceId._4 |
Configure metrics collection​
In this section, you will configure a pipeline for shipping metrics from Azure Monitor to an Event Hub, on to an Azure Function, and finally to an HTTP Source on a hosted collector in Sumo Logic.
- Create hosted collector and tag
tenant_name
field. - Configure an HTTP Source.
- Configure and deploy the ARM Template.
- Export metrics to Event Hub. Perform the following steps for each Azure Cosmos DB account that you want to monitor.
- Choose Stream to an event hub as destination.
- Select all the metrics under Metrics section.
- Use the Event Hub namespace created by the ARM template in the previous step. You can create a new Event Hub or use the one created by the ARM template. You can use the default policy
RootManageSharedAccessKey
as the policy name.
- Tag the location field in the source with right location value.
Currently, only Azure Cosmos DB for NoSQL database account type supports exporting metrics using diagnostic settings.
Configure logs collection​
In this section, you will configure a pipeline for shipping diagnostic logs from Azure Monitor to an Event Hub.
- To set up the Azure Event Hubs source in Sumo Logic, refer to Azure Event Hubs Source for Logs.
- If you want to audit Azure Cosmos DB control plane operations, disable the key based metadata write access.
- To create the diagnostic settings in Azure portal, refer to the Azure documentation. Perform the following steps for each Azure Cosmos DB account that you want to monitor.
- Choose Stream to an event hub as the destination.
- Select your preferred log categories depending upon your database API or select allLogs.
- Use the Event Hub namespace and Event Hub name configured in the previous step in the destination details section. You can use the default policy
RootManageSharedAccessKey
as the policy name.
- Tag the location field in the source with right location value.
Activity logs (optional)​
To collect activity logs, follow the instructions here. If you are already collecting activity logs for a subscription, do not perform this step.
Since this source contains logs from multiple regions, make sure that you do not tag this source with the location tag.
Enabling Microsoft Defender for Cloud​
For security events, make sure you enable Microsoft Defender for Cloud. In the Defender Plans Settings page toggle the Databases status under the Cloud Workload Protection section and select the resource types.
Installing the Azure Cosmos DB app​
This section provides instructions on how to install the Azure Cosmos DB app, and shows examples of each of the preconfigured dashboards you can use to analyze your data.
To install the app, do the following:
- Select App Catalog.
- In the 🔎 Search Apps field, run a search for your desired app, then select it.
- Click Install App.
note
Sometimes this button says Add Integration.
- Click Next in the Setup Data section.
- In the Configure section of your respective app, complete the following fields.
- Key. Select either of these options for the data source.
- Choose Source Category and select a source category from the list for Default Value.
- Choose Custom, and enter a custom metadata field. Insert its value in Default Value.
- Key. Select either of these options for the data source.
- Click Next. You will be redirected to the Preview & Done section.
Post-installation
Once your app is installed, it will appear in your Installed Apps folder, and dashboard panels will start to fill automatically.
Each panel slowly fills with data matching the time range query and received since the panel was created. Results will not immediately be available, but will update with full graphs and charts over time.
Viewing the Azure Cosmos DB dashboards​
All dashboards have a set of filters that you can apply to the entire dashboard. Use these filters to drill down and examine the data to a granular level.
- You can change the time range for a dashboard or panel by selecting a predefined interval from a drop-down list, choosing a recently used time range, or specifying custom dates and times. Learn more.
- You can use template variables to drill down and examine the data on a granular level. For more information, see Filtering Dashboards with Template Variables.
- Most Next-Gen apps allow you to provide the scope at the installation time and are comprised of a key (
_sourceCategory
by default) and a default value for this key. Based on your input, the app dashboards will be parameterized with a dashboard variable, allowing you to change the dataset queried by all panels. This eliminates the need to create multiple copies of the same dashboard with different queries.
Overview​
The Azure Cosmos DB - Overview dashboard provides details about RU (Request Unit) consumption, duration, status code distribution across database and collection.
Use this dashboard to:
- Track data plane request locations for cross region calls.
- Monitor request units, duration consumed across database and collection.
- Identify failed requests across database and collection.
Throughput​
The Azure Cosmos DB - Throughput dashboard provides details about Request Unit (RU) consumption for logical partition keys in each region, within each of their physical partitions.
Use this dashboard to:
- Identify hot partitions from a request volume perspective.
- Track request units consumed by each database.
Audit​
The Azure Cosmos DB - Audit dashboard provides details about all control plane operations executed on the account.
Use this dashboard to:
- Monitor control plane requests which includes modifications to the regional failover policy, indexing policy, IAM role assignments, backup/restore policies, VNet and firewall rules, private links as well as updates, and deletes of the account.
- Monitor data plane operations executed to create, update, delete, or retrieve data within the account.
- Use operation name filter to track important events like network settings update, account key rotations, provisioned throughput changes and replication settings update.
Storage​
The Azure Cosmos DB - Storage dashboard provides details about data usage, document count, and physical partition size by database.
Use this dashboard to:
- Identify logical partition keys that have consumed more storage space than others.
- Track document count and data usage.
Performance​
The Azure Cosmos DB - Performance dashboard provides insights into the performance of your Azure Cosmos DB databases. This includes metrics on query duration, server side latency, and failed queries.
Use this dashboard to:
- Monitor and analyze the failed queries of your Azure Cosmos DB.
- Identify performance bottlenecks and optimize query execution.
Queries​
The Azure Cosmos DB - Queries dashboard provides insights into the queries executed in your Azure Cosmos DB databases.
Use this dashboard to:
- Analyze query distribution across duration, request charge, response length.
- Identify query bottlenecks and optimize query execution.
Health​
The Azure Cosmos DB - Health dashboard provides information of any service health incidents or resource health events associated with Azure Cosmos DB accounts in your azure account.
Use this dashboard to:
- View recent resource and service health incidents.
- View distribution of service and resource health by incident type.
- Monitor service availability.
Policy and Recommendations​
The Azure Cosmos DB - Policy and Recommendations dashboard provides information of all effect action operations performed by Azure policy and recommendations events from Azure Advisor.
Use this dashboard to:
- Monitor policy events with warnings and errors.
- View recent failed policy events.
- View total recommendation events.
- Identify high impact recommendations.
- View recent recommendation events and navigate to the affected resource.
Administrative Operations​
The Azure Cosmos DB - Administrative Operations dashboard provides details on users performing admin operations.
Use this dashboard to:
- Identify top users performing administrative operations.
- View top 10 operations that caused the most errors.
- View recent diagnostic, network, and replication settings updates operations.
Upgrade/Downgrade the Azure Cosmos DB app (optional)​
To update the app, do the following:
- Select App Catalog.
- In the Search Apps field, search for and then select your app.
Optionally, you can identify apps that can be upgraded in the Upgrade available section. - To upgrade the app, select Upgrade from the Manage dropdown.
- If the upgrade does not have any configuration or property changes, you will be redirected to the Preview & Done section.
- If the upgrade has any configuration or property changes, you will be redirected to Setup Data page.
- In the Configure section of your respective app, complete the following fields.
- Key. Select either of these options for the data source.
- Choose Source Category and select a source category from the list for Default Value.
- Choose Custom and enter a custom metadata field. Insert its value in Default Value.
- Key. Select either of these options for the data source.
- Click Next. You will be redirected to the Preview & Done section.
- In the Configure section of your respective app, complete the following fields.
Post-update
Your upgraded app will be installed in the Installed Apps folder, and dashboard panels will start to fill automatically.
See our Release Notes changelog for new updates in the app.
To revert the app to a previous version, do the following:
- Select App Catalog.
- In the Search Apps field, search for and then select your app.
- To version down the app, select Revert to < previous version of your app > from the Manage dropdown.
Uninstalling the Azure Cosmos DB app (optional)​
To uninstall the app, do the following:
- Select App Catalog.
- In the 🔎 Search Apps field, run a search for your desired app, then select it.
- Click Uninstall.
Troubleshooting​
HTTP Logs and Metrics Source used by Azure Functions​
To troubleshoot metrics collection, follow the instructions in Collect Metrics from Azure Monitor > Troubleshooting metrics collection.