Open egressyk opened 10 months ago
Thank you for your feedback. Tagging and routing to the team member best able to assist.
Issue still present in 1.3.1:
DateTimeOffset now = DateTime.UtcNow;
DateTimeOffset beginningOfMonth = new DateTime(now.Year, now.Month, 1);
var options = new MetricsQueryOptions()
{
Aggregations = { MetricAggregationType.Average },
Filter = "Instance eq '*'",
TimeRange = new QueryTimeRange(beginningOfMonth, now)
};
// Retrieve telemetry data
var response = await MetricsQueryClient.QueryResourceAsync(...)
Error thrown: 'Detected invalid time interval input, etc'
Facing the same issue with MetricsClient. Because of this bug unable to set the TimeRange.
`
string id = "/subscriptions/
MetricsQueryResourcesOptions options = new()
{
Granularity = TimeSpan.FromMinutes(30),
TimeRange = new QueryTimeRange(DateTimeOffset.UtcNow.AddDays(-7), DateTimeOffset.UtcNow)
};
options.Aggregations.Add("maximum");
MetricsQueryResourcesResult metric = await metricsClient.QueryResourcesAsync(resourceIds: [new(id)],
metricNames: ["UsageNanoCores"],
metricNamespace: "Microsoft.App/containerApps",
options: options,
cancellationToken: cancellationToken);
`
RequestFailedException: Detected invalid time interval input: 2024-05-23 5:43:22 AM 00:00/2024-05-30 5:43:22 AM 00:00, supported Iso 8601 time interval format: (Datetime/Datetime, Datetime/Duration, Duration/Datetime, Duration) Status: 400 (Bad Request) ErrorCode: BadRequest
Content: {"error":{"additionalInfo":[{"type":"string","info":"TraceId=xxxxxxxxxxxxxx"},{"type":"string","info":"DateTime=2024-05-30T05:43:40.8507138Z"},{"type":"string","info":"ExceptionType=Microsoft.Online.Metrics.MetricsMP.Utilities.RPRequestFormatException"}],"code":"BadRequest","message":"Detected invalid time interval input: 2024-05-23 5:43:22 AM 00:00/2024-05-30 5:43:22 AM 00:00, supported Iso 8601 time interval format: (Datetime/Datetime, Datetime/Duration, Duration/Datetime, Duration)"}}
This error occurs because the MetricsClient uses a ToString
on the Start & End of the TimeRange property.
Definitely a bug :)
As ugly work arround we created a HttpPipelinePolicy to modify the request message.
Facing the same issue, which means I cannot retrieve MetricsQueryClient data for a time range in the past.
Any update on a possible fix?
Library name and version
Azure.Monitor.Query 1.2.0
Describe the bug
Using MetricsQueryClient.QueryResourceAsync() with option TimeRange of QueryTimeRange(startTime, endTime) causes and error, opposed to TimeRange of QueryTimeRange(duration).
Exception or Stack Trace 'Detected invalid time interval input: 2023-11-15T10:12:25.4174057 01:00/2023-11-15T11:12:25.4174057 01:00, supported Iso 8601 time interval format: (Datetime/Datetime, Datetime/Duration, Duration/Datetime, Duration) Status: 400 (Bad Request) ErrorCode: BadRequest
Expected behavior
Receive the same result as if used with
Actual behavior
Receiving Status: 400 (Bad Request)
Reproduction Steps
Environment
Windows 10
VisualStudio 17.6.4
.NET 7.0
Azure.Monitor.Query 1.2.0