简体   繁体   English

如何获取 Azure Cosmos DB 的每个分区的使用量大小?

[英]How to get the usage size for each partition of Azure Cosmos DB?

How to get the usage size for each partition of Azure Cosmos DB?如何获取 Azure Cosmos DB 的每个分区的使用量大小?

I would like to get the usage size for each partition of Cosmos DB.我想获取 Cosmos DB 的每个分区的使用大小。

I ran Rest API according to the following site, but I get the following error.我根据以下站点运行了 Rest API ,但出现以下错误。

curl -X GET -L -H "Content-Type: application / json" -H "Authorization: Bearer xxxx" https://{account}.documents.azure.com/dbs/{db}/colls/ {collection}

{"code": "BadRequest", "message": "Invalid API version. Ensure a valid x-ms-version header value is passed. Please update to the latest version of Azure Cosmos DB SDK. \ r \ nActivityId: 9993e774- 4b66-4ba0-b71b-2f4ad0edc754, Microsoft.Azure.Documents.Common/2.14.0 "} {"code": "BadRequest", "message": "Invalid API version. Ensure a valid x-ms-version header value is passed. Please update to the latest version of Azure Cosmos DB SDK. \ r \ nActivityId: 9993e774- 4b66-4ba0-b71b-2f4ad0edc754,Microsoft.Azure.Documents.Common/2.14.0“}

https://docs.microsoft.com/en-us/azure/cosmos-db/monitor-cosmos-db https://docs.microsoft.com/en-us/azure/cosmos-db/monitor-cosmos-db

I'm trying to get the partition size with Azure Java Cosmos SDK v4, but I don't have the following class that was in SDK v2, so I don't know which class to use in v4. I'm trying to get the partition size with Azure Java Cosmos SDK v4, but I don't have the following class that was in SDK v2, so I don't know which class to use in v4.

https://docs.microsoft.com/en-us/java/api/com.microsoft.azure.documentdb.partitionkeystatistics?view=azure-java-stable https://docs.microsoft.com/en-us/java/api/com.microsoft.azure.documentdb.partitionkeystatistics?view=azure-java-stable

Can anyone give me some advice?谁能给我一些建议?

Thank you Andy .谢谢安迪 Posting your suggestion as an answer to help other community members.发布您的建议作为帮助其他社区成员的答案。

if you are sending a GET, you don't need a Content-Type header, but you probably want an Accept header.如果您要发送 GET,则不需要Content-Type header,但您可能需要 Accept header。 So change it to -H "Accept: application/json"所以把它改成-H "Accept: application/json"

{"code": "BadRequest", "message": "Invalid API version. Ensure a valid x-ms-version header value is passed. Please update to the latest version of Azure Cosmos DB SDK.

To fix the above error, you can try adding the latest x-ms-version as -H "x-ms-version: 2018-12-31"要修复上述错误,您可以尝试将最新的x-ms-version添加为-H "x-ms-version: 2018-12-31"

You can refer to Supported REST API Versions您可以参考支持的 REST API 版本

Alternatively, you can use Azure Monitor with Log Analytics to query the size of the partition, refer to How to find the size of logical partition in a Cosmos container或者,您可以使用 Azure Monitor with Log Analytics 来查询分区的大小,请参阅如何在 Cosmos 容器中查找逻辑分区的大小

If you still have doubts, you can open an issue on GitHub: azure-sdk-for-java如果您仍有疑问,可以在 GitHub 上打开一个问题: azure-sdk-for-java

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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