[BUG] SubscriptionResourceGetMonitorMetricsOptions does not accept more than one metrics
See original GitHub issueLibrary 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:
- Created 3 months ago
- Comments:5 (2 by maintainers)
Top GitHub Comments
Hi @dvbb, I double checked, now I could not reproduce it as well. I guess we can close the bug.
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.