-
Notifications
You must be signed in to change notification settings - Fork 19
Open
Labels
Description
Link to sample
Library name and version
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/cosmos/armcosmos/v3" or
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/cosmos/armcosmos/v4"
Language of the Sample
- C#/.NET
- Java
- JavaScript/TypedScript
- Python
- Golang
- Other - Please specify in Issue details field
Sample Issue Type
- Sample not working
- Sample missing
- Do not understand sample
Issue details
Filter parsing seem to fail.
Additionally, the $filter
param is duplicated as the library seems to add it (but it doesn't work also when omitting it).
Expected behavior
Return list of metrics.
Actual behavior
2025/07/01 15:57:16 GET https://management.azure.com/subscriptions/[subId]/resourceGroups/[rg]/providers/Microsoft.DocumentDB/databaseAccounts/[cosmosAccount]/metrics
--------------------------------------------------------------------------------
RESPONSE 400: 400 Bad Request
ERROR CODE: BadRequest
--------------------------------------------------------------------------------
{
"code": "BadRequest",
"message": "Failed to parse query $filter=(value eq 'total requests') and timegrain eq 'pt5m' and starttime eq '2017-11-19t23:53:55.2780000z' and endtime eq '2017-11-20t00:13:55.2780000z\r\nActivityId: d317192a-2135-4546-9193-df3e49dd7ff8, Microsoft.Azure.Documents.Common/2.14.0"
}
--------------------------------------------------------------------------------
exit status 1
Reproduction Steps
cosmosClientFactory, err = armcosmos.NewClientFactory(subscriptionID, cred, nil)
if err != nil {
log.Fatal(err)
}
databaseAccountsClient = cosmosClientFactory.NewDatabaseAccountsClient()
resourceGroupName := ...
accountName := ...
databaseId := ...
containerId := ...
metricsPager := databaseAccountsClient.NewListMetricsPager(resourceGroupName, accountName, "$filter=(name.value eq 'Total Requests') and timeGrain eq duration'PT5M' and startTime eq '2017-11-19T23:53:55.2780000Z' and endTime eq '2017-11-20T00:13:55.2780000Z", nil)
for metricsPager.More() {
page, err := metricsPager.NextPage(ctx)
if err != nil {
log.Fatal(err)
}
for _, metric := range page.Value {
// Before reading a value, you MUST check that the pointer is not nil
if metric.Name != nil && metric.Name.Value != nil {
// Dereference the pointers with * to get the actual values
metricName := *metric.Name.Value
fmt.Printf("Metric: %s\n", metricName)
}
}
}
Environment
MacOS, Silicon M4.