简体   繁体   中英

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?

I would like to get the usage size for each partition of Cosmos DB.

I ran Rest API according to the following site, but I get the following error.

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 "}

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.

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. So change it to -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"

You can refer to Supported REST API Versions

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

If you still have doubts, you can open an issue on GitHub: azure-sdk-for-java

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