Skip to content

Commit

Permalink
try subtract time range
Browse files Browse the repository at this point in the history
  • Loading branch information
hkfgo committed May 4, 2024
1 parent 295fd9e commit 6ed5825
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ private async Task<MetricResult> GetRelevantMetric(string resourceId, string met
MetricsQueryOptions queryOptions;
var querySizeLimit = metricLimit ?? Defaults.MetricDefaults.Limit;
var historyStartingFromInHours = _azureMonitorIntegrationConfiguration.Value.History.StartingFromInHours;
_logger.LogWarning("Querying range {start}, {finish}", new DateTimeOffset(recordDateTime), new DateTimeOffset(recordDateTime.AddHours(historyStartingFromInHours)));
_logger.LogWarning("Querying range {start}, {finish}", new DateTimeOffset(recordDateTime.AddHours(-historyStartingFromInHours)), new DateTimeOffset(recordDateTime));
if (metricDimensions.Any())
{
var metricDimensionsFilter = string.Join(" and ", metricDimensions.Select(metricDimension => $"{metricDimension} eq '*'"));
Expand All @@ -230,7 +230,7 @@ private async Task<MetricResult> GetRelevantMetric(string resourceId, string met
},
Filter = metricDimensionsFilter,
Size = querySizeLimit,
TimeRange= new QueryTimeRange(new DateTimeOffset(recordDateTime), new DateTimeOffset(recordDateTime.AddHours(historyStartingFromInHours)))
TimeRange= new QueryTimeRange(new DateTimeOffset(recordDateTime.AddHours(-historyStartingFromInHours)), new DateTimeOffset(recordDateTime))
};
}
else
Expand All @@ -240,7 +240,7 @@ private async Task<MetricResult> GetRelevantMetric(string resourceId, string met
metricAggregation
},
Size = querySizeLimit,
TimeRange= new QueryTimeRange(new DateTimeOffset(recordDateTime), new DateTimeOffset(recordDateTime.AddHours(historyStartingFromInHours)))
TimeRange= new QueryTimeRange(new DateTimeOffset(recordDateTime.AddHours(-historyStartingFromInHours)), new DateTimeOffset(recordDateTime))
};
}

Expand Down

0 comments on commit 6ed5825

Please sign in to comment.