I have updated Azure sdk to new version, but I cannot get metrics from metrics_client

Zhenlong Zou 0 Reputation points
2025-02-05T19:38:43.9266667+00:00

I got this error:

|GET https://management.azure.com/subscriptions/6ddf7e68-372e-4965-9318-8666c7502426/resourceGroups/s-o1g1e/providers/Microsoft.Network/loadBalancers/s-o1g1e-public-3/providers/Microsoft.Insights/metrics

RESPONSE 400: 400 Bad Request ERROR CODE: BadRequest

{
"code": "BadRequest",
"message": "Received invalid query parameter: [$filter, BackendIpAddress+eq+%27%2A%27],[aggregation, ],[api-version, 2021-05-01],[interval, PT1M],[metricnames, DipAvailability],[resultType, Data],[timespan, 2025-02-05T01%3A07%3A19Z%2F2025-02-05T01%3A12%3A19Z], TraceId: 3990fdc6-4319-45ad-a24f-f191a3f5ab6c for request: subscriptions/6ddf7e68-372e-4965-9318-8666c7502426/resourceGroups/s-o1g1e/providers/Microsoft.Network/loadBalancers/s-o1g1e-public-3/providers/Microsoft.Insights/metrics"
}| | -------- | |The code difference between new call and new call is:|

// new code: Create the options struct for the request
options := &armmonitor.MetricsClientListOptions{
   Timespan:    ×pan,
   Interval:    &ival,
   Metricnames: &metricNames,
   Aggregation: &aggregation,
   Top:         count,
   Filter:      &filter,
   ResultType:  to.Ptr(armmonitor.ResultTypeData),
}

result, err := mc.List(ctx, resourceURI, options)

old code:
result, err := mc.List(ctx, resourceURI, timespan, &ival, metricNames, aggregation, count, "", filter, insights.ResultTypeData, "")

can you help me with it?

Azure Monitor
Azure Monitor
An Azure service that is used to collect, analyze, and act on telemetry data from Azure and on-premises environments.
3,448 questions
0 comments No comments
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.