fix: set interval (granularity) in Azure Monitor API request#7526
fix: set interval (granularity) in Azure Monitor API request#7526nicknikolakakis wants to merge 2 commits into
Conversation
|
Thank you for your contribution! 🙏 Please understand that we will do our best to review your PR and give you feedback as soon as possible, but please bear with us if it takes a little longer as expected. While you are waiting, make sure to:
Once the initial tests are successful, a KEDA member will ensure that the e2e tests are run. Once the e2e tests have been successfully completed, the PR may be merged at a later date. Please be patient. Learn more about our contribution guide. |
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
|
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. |
The azure-monitor scaler was not setting the Interval parameter when querying Azure Monitor metrics. Without it, Azure defaults to PT1M granularity, returning multiple data points within the timespan. Since verifyAggregationTypeIsSupported only reads the last data point, the Total aggregation over a 15-minute window would only return the last 1-minute bucket instead of the sum over the full window. Set Interval equal to the timespan duration so Azure returns a single aggregated data point covering the entire window. Fixes kedacore#7524 Signed-off-by: Nick Nikolakakis <nonicked@protonmail.com>
- Extract "PT5M" into defaultAggregationInterval constant - Sort changelog entry alphabetically (Azure before Cron) Signed-off-by: Nick Nikolakakis <nonicked@protonmail.com>
c268bdb to
27ef61c
Compare
Fixes #7524
Summary
The azure-monitor scaler was not setting the
Interval(granularity) parameter when querying the Azure Monitor metrics API. Without it, Azure defaults toPT1Mgranularity, returning multiple data points within the timespan. SinceverifyAggregationTypeIsSupportedonly readsdata[len(data)-1](the last data point), theTotalaggregation over a 15-minute window would only return the last 1-minute bucket's value instead of the sum over the full window.Changes
formatTimeSpannow also returns an ISO 8601 duration string (e.g.,PT15M) matching the timespan, andrequestMetricpasses it asopts.IntervalmetricAggregationIntervalis configured, both timespan and interval default to 5 minutes (PT5M)toISO8601DurationandformatTimeSpanHow it works
Interval: nil→ Azure returns multiple 1-min bucketsInterval: "PT15M"→ Azure returns a single data point