Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not able to get partition_id in cosmosdb #124

Open
patwapro opened this issue Feb 7, 2023 · 2 comments
Open

Not able to get partition_id in cosmosdb #124

patwapro opened this issue Feb 7, 2023 · 2 comments

Comments

@patwapro
Copy link

patwapro commented Feb 7, 2023

Hi,
I am using CollectionPartitionOperations -> list_metrics.

metrics = client.collection_partition.list_metrics(
        resource_group,
        account_name,
        database_rid,
        container_rid,
        "(name.value eq 'Data Size') and timeGrain eq duration'P1D' and startTime eq '2023-01-01T13:53:55.2780000Z' and endTime eq '2023-01-31T15:58:55.2780000Z'"
    )

for metric in metrics:
        print(metric)

Not printing anything.

I set 80,000 throughputs in my container.

We are using:
Python Azure SDK - azure-mgmt-cosmosdb==6.4.0
The document we follow:
https://learn.microsoft.com/en-us/python/api/azure-mgmt-cosmosdb/azure.mgmt.cosmosdb.operations.collectionpartitionoperations?view=azure-python

@aayush3011
Copy link

aayush3011 commented Feb 9, 2023

Please follow the below sample to correctly get the list_metrics.

https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/cosmos/azure-mgmt-cosmosdb/generated_samples/cosmos_db_collection_get_metrics.py

The code should be like this:

metrics = client.collection_partition.list_metrics(
       resource_group,
       account_name,
       database_rid,
       container_rid,
       "$filter=(name.value eq 'Data Size') and timeGrain eq duration'P1D' and startTime eq '2023-01-01T13:53:55.2780000Z' and endTime eq '2023-01-31T15:58:55.2780000Z'"
   )

for metric in metrics:
       print(metric)

You have to include the "$filter=" in the filter string.

@patwapro
Copy link
Author

I got this issue:

HttpResponseError: (BadRequest) Failed to parse query $filter=(value eq 'data size') and timegrain eq 'p1d' and starttime eq '2023-01-01t13:53:55.2780000z' and endtime eq '2023-01-31t15:58:55.2780000z'
ActivityId: c6a9ae91-a912-11ed-b4cf-5414f357addb, Microsoft.Azure.Documents.Common/2.14.0
Code: BadRequest
Message: Failed to parse query $filter=(value eq 'data size') and timegrain eq 'p1d' and starttime eq '2023-01-01t13:53:55.2780000z' and endtime eq '2023-01-31t15:58:55.2780000z'
ActivityId: c6a9ae91-a912-11ed-b4cf-5414f357addb, Microsoft.Azure.Documents.Common/2.14.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants