question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] SubscriptionResourceGetMonitorMetricsOptions does not accept more than one metrics

See original GitHub issue

Library name and version

Azure.ResourceManager.Monitor.Models

Describe the bug

The SubscriptionResourceGetMonitorMetricsOptions class (used by GetMonitorMetrics(options)' method of the 'SubscriptionResource class) has a property:

        /// <summary> The names of the metrics (comma separated) to retrieve. </summary>
        public string Metricnames { get; set; }

As it seems it should get the demanded metrics based on a string like: "Network In,Network Out" or "Network In, Network Out" However, when I set it as:

options.Metricnames = "Network In, Network Out";

or

options.Metricnames = string.Join(", ", new[] {"Network In", "Network Out"});

I get the error: {"error":{"additionalInfo":[{"type":"string","info":"TraceId={d696c57f-e7bf-4027-8597-7e3d334b92bb}"},{"type":"string","info":"ExceptionType=Microsoft.Online.Metrics.MetricsMP.Utilities.RPRequestFormatException"}],"code":"BadReq uest","message":"Failed to find metric configuration for provider: Microsoft.Compute, resource Type: virtualMachines, metric: Network In, Network Out, Valid metrics: Percentage CPU,Network In,Network Out,Disk Read Bytes,Disk Wri te Bytes,Disk Read Operations/Sec,Disk Write Operations/Sec,CPU Credits Remaining,CPU Credits Consumed,Data Disk Read Bytes/sec,Data Disk Write Bytes/sec,Data Disk Read Operations/Sec,Data Disk Write Operations/Sec,Data Disk Que ue Depth,Data Disk Bandwidth Consumed Percentage,Data Disk IOPS Consumed Percentage,Data Disk Target Bandwidth,Data Disk Target IOPS,Data Disk Max Burst Bandwidth,Data Disk Max Burst IOPS,Data Disk Used Burst BPS Credits Percent age,Data Disk Used Burst IO Credits Percentage,OS Disk Read Bytes/sec,OS Disk Write Bytes/sec,OS Disk Read Operations/Sec,OS Disk Write Operations/Sec,OS Disk Queue Depth,OS Disk Bandwidth Consumed Percentage,OS Disk IOPS Consum ed Percentage,OS Disk Target Bandwidth,OS Disk Target IOPS,OS Disk Max Burst Bandwidth,OS Disk Max Burst IOPS,OS Disk Used Burst BPS Credits Percentage,OS Disk Used Burst IO Credits Percentage,Premium Data Disk Cache Read Hit,Pr emium Data Disk Cache Read Miss,Premium OS Disk Cache Read Hit,Premium OS Disk Cache Read Miss,VM Cached Bandwidth Consumed Percentage,VM Cached IOPS Consumed Percentage,VM Uncached Bandwidth Consumed Percentage,VM Uncached IOPS Consumed Percentage,Available Memory Bytes,VmAvailabilityMetric,VM Remote Used Burst IO Credits Percentage,VM Remote Used Burst BPS Credits Percentage,VM Local Used Burst IO Credits Percentage,VM Local Used Burst BPS Credits Pe rcentage"}} When I use just one metric, like:

options.Metricnames = "Network In";

or

options.Metricnames = "Network Out";

everything works as it should (it gets the required metrics). Retrieving multiple metrics with a corresponding number of requests works as well. I assume there is no option of retrieving multiple metrics in one request.

Expected behavior

According to the documentation it should be possible to retrieve multiple metrics from Azure with a single request, by usign a single string with comma separated names of metrics, like: "Percentage CPU,Network In,Network Out,Disk Read Bytes"

Actual behavior

It gives an error: `{“error”:{“additionalInfo”:[{“type”:“string”,“info”:“TraceId={d696c57f-e7bf-4027-8597-7e3d334b92bb}”},{“type”:“string”,“info”:“ExceptionType=Microsoft.Online.Metrics.MetricsMP.Utilities.RPRequestFormatException”}],“code”:“BadReq uest”,“message”:“Failed to find metric configuration for provider: Microsoft.Compute, resource Type: virtualMachines, metric: Network In, Network Out, Valid metrics: Percentage CPU,Network In,Network Out,Disk Read Bytes,Disk Wri te Bytes,Disk Read Operations/Sec,Disk Write Operations/Sec,CPU Credits Remaining,CPU Credits Consumed,Data Disk Read Bytes/sec,Data Disk Write Bytes/sec,Data Disk Read Operations/Sec,Data Disk Write Operations/Sec,Data Disk Que ue Depth,Data Disk Bandwidth Consumed Percentage,Data Disk IOPS Consumed Percentage,Data Disk Target Bandwidth,Data Disk Target IOPS,Data Disk Max Burst Bandwidth,Data Disk Max Burst IOPS,Data Disk Used Burst BPS Credits Percent age,Data Disk Used Burst IO Credits Percentage,OS Disk Read Bytes/sec,OS Disk Write Bytes/sec,OS Disk Read Operations/Sec,OS Disk Write Operations/Sec,OS Disk Queue Depth,OS Disk Bandwidth Consumed Percentage,OS Disk IOPS Consum ed Percentage,OS Disk Target Bandwidth,OS Disk Target IOPS,OS Disk Max Burst Bandwidth,OS Disk Max Burst IOPS,OS Disk Used Burst BPS Credits Percentage,OS Disk Used Burst IO Credits Percentage,Premium Data Disk Cache Read Hit,Pr emium Data Disk Cache Read Miss,Premium OS Disk Cache Read Hit,Premium OS Disk Cache Read Miss,VM Cached Bandwidth Consumed Percentage,VM Cached IOPS Consumed Percentage,VM Uncached Bandwidth Consumed Percentage,VM Uncached IOPS Consumed Percentage,Available Memory Bytes,VmAvailabilityMetric,VM Remote Used Burst IO Credits Percentage,VM Remote Used Burst BPS Credits Percentage,VM Local Used Burst IO Credits Percentage,VM Local Used Burst BPS Credits Pe rcentage”}}

Reproduction Steps

async Task CollectMetricsForVirtualMachines(string subscriptionId, string location)
{
        var startDate = DateTime.UtcNow.AddDays(-10);
        var stopDate = DateTime.UtcNow;
        var options = new SubscriptionResourceGetMonitorMetricsOptions(location);
        options.Metricnames = "Percentage CPU,Network In,Network Out,Disk Read Bytes";
        options.Timespan = $"{startDate:o}/{stopDate:o}";
        options.Metricnamespace = "Microsoft.Compute/virtualMachines";

        var resourceIdentifier = SubscriptionResource.CreateResourceIdentifier(subscriptionId);
        SubscriptionResource subscription = await client.GetSubscriptionResource(resourceIdentifier).GetAsync();
        
        var metrics = subscription.GetMonitorMetrics(options).ToList();
}

Environment

.NET SDK: Version: 8.0.100-preview.4.23260.5 Commit: 2268e7b15c

Runtime Environment: OS Name: Windows OS Version: 10.0.19045 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\8.0.100-preview.4.23260.5\

.NET workloads installed: There are no installed workloads to display.

Host: Version: 8.0.0-preview.4.23259.5 Architecture: x64 Commit: 84a3d0e37e

.NET SDKs installed: 6.0.410 [C:\Program Files\dotnet\sdk] 7.0.200 [C:\Program Files\dotnet\sdk] 7.0.203 [C:\Program Files\dotnet\sdk] 7.0.302 [C:\Program Files\dotnet\sdk] 8.0.100-preview.4.23260.5 [C:\Program Files\dotnet\sdk]

Issue Analytics

  • State:closed
  • Created 3 months ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
af-af-afcommented, Aug 4, 2023

Hi @dvbb, I double checked, now I could not reproduce it as well. I guess we can close the bug.

0reactions
github-actions[bot]commented, Jul 31, 2023

Hi @af-af-af. Thank you for opening this issue and giving us the opportunity to assist. To help our team better understand your issue and the details of your scenario please provide a response to the question asked above or the information requested above. This will help us more accurately address your issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

SubscriptionResourceGetMonitor...
Metric namespace where the metrics you want reside. Orderby. The aggregation to use for sorting results and the direction of the sort. Only...
Read more >
Multiple metrics in keras - why and when might we want to use ...
Here, both the mean_absolute_error and accuracy are selected. It is not explained, however, why and when specifying two or more metrics might be ......
Read more >
Log multiple metrics while training - 🤗Datasets
Hi, I am fine-tuning a classification model and would like to log accuracy, precision, recall and F1 using Trainer API.
Read more >
How to fix the error "For multi-metric scoring ...
2 Answers. Refit an estimator using the best found parameters on the whole dataset. For multiple metric evaluation, this needs to be a...
Read more >
Use metric math - Amazon CloudWatch - AWS Documentation
Metric math enables you to query multiple CloudWatch metrics and use math expressions to create new time series based on these metrics. You...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found