【问题标题】:Azure Rest API to fetch RU Metrics of Cosmos DB accountAzure Rest API 用于获取 Cosmos DB 帐户的 RU 指标
【发布时间】:2022-01-02 14:27:18
【问题描述】:

我正在尝试使用 Azure Monitor REST API 在 dot net 应用程序中以编程方式获取 azure cosmos DB 的标准化 RU(请求单位)指标,但无法继续。

我从官方文档中找到了这个 API,但不确定要提供哪些参数才能获得所需的结果。

获取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}

谁能指出我正确的方向(任何视频/博客/文档)?

【问题讨论】:

标签: .net azure api rest


【解决方案1】:

我们可以将 .NET Cosmos DB SDK 与 DocumentClient 类一起使用,或者使用现有的 MongoDB SDK,或者直接利用 Azure Cosmos DB REST API - 所有这些都提供了接收消耗的请求单元的机会:

// 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;

请参阅此Github link 以计算 Azure Cosmos DB 中的请求单位。

【讨论】:

    猜你喜欢
    • 2021-08-14
    • 2022-01-19
    • 1970-01-01
    • 1970-01-01
    • 2020-01-09
    • 1970-01-01
    • 2021-11-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多