简体   繁体   中英

Azure Rest API to fetch RU Metrics of Cosmos DB account

I am trying to fetch the normalized RU(Request Units) Metric of azure cosmos DB programmatically in a dot net application using Azure Monitor REST APIs but unable to proceed.

I found this API from official docs but not sure what parameters to give so as to get the desired results.

GET https://management.azure.com/{resourceUri}/providers/Microsoft.Insights/metrics?timespan={timespan}&interval={interval}&metricnames={metricnames}&aggregation={aggregation}&top={top}&orderby={orderby}&$filter={$filter}&resultType={resultType}&api-version=2018-01-01&metricnamespace={metricnamespace}

Can anyone point me in the right direction(Any videos/blogs/docs)?

We can use .NET Cosmos DB SDK with the DocumentClient class, or using existing MongoDB SDKs or just leveraging the Azure Cosmos DB REST API directly - all of them provide the opportunity to receive the consumed Request Units:

// https://docs.microsoft.com/en-us/azure/cosmos-db/performance-tips#throughput
var client = new DocumentClient(new Uri(accountEndpoint), accountKey);

ResourceResponse<Document> response = await client.CreateDocumentAsync(collectionSelfLink, myDocument);

var requestCharge = response.RequestCharge;

Refer this Github link to calculate the Request Units in Azure Cosmos DB.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM