Warm tip: This article is reproduced from serverfault.com, please click

azure-如何通过暴露的api检索cosmosdb的查询统计信息?

(azure - how to retrieve the query stats for a cosmosdb through rest api exposed?)

发布于 2020-11-28 12:22:03

我想获取JSON或azure cosmosdb支持的任何其他格式的容器的查询统计信息。有没有办法从azure cosmosdb通过暴露的api获取特定查询的查询统计信息?

Questioner
Peeyush Mishra
Viewed
11
Steve Zhao 2020-11-30 10:04:30

你可以从响应标头获取查询统计信息。

代码:

var qry = new SqlQuerySpec { query = "SELECT * FROM root" };
var result = await client.PostWithNoCharSetAsync(new Uri(baseUri, resourceLink), qry);
            //get response header
Console.WriteLine("result:" + result);
            //get documents
Console.WriteLine("result content:" + result.Content.ReadAsStringAsync().Result);

结果: 在此处输入图片说明

你可以在此处获取代码示例。https://github.com/Azure/azure-cosmos-dotnet-v2/blob/master/samples/rest-from-.net/Program.cs