fix: make Azure billing usage and forecast windows configurable#52209
Draft
stefans-elastic wants to merge 1 commit into
Draft
fix: make Azure billing usage and forecast windows configurable#52209stefans-elastic wants to merge 1 commit into
stefans-elastic wants to merge 1 commit into
Conversation
Contributor
🤖 GitHub commentsJust comment with:
|
stefans-elastic
force-pushed
the
fix/azure_billing_make_lookback_window_configurable
branch
from
July 22, 2026 13:47
0b9cdd2 to
5afc628
Compare
Contributor
|
This pull request does not have a backport label.
To fixup this pull request, you need to add the backport labels for the needed
|
stefans-elastic
force-pushed
the
fix/azure_billing_make_lookback_window_configurable
branch
from
July 22, 2026 14:08
5afc628 to
9e64196
Compare
Contributor
Contributor
✅ Elastic Docs Style Checker (Vale)No issues found on modified lines! The Vale linter checks documentation changes against the Elastic Docs style guide. To use Vale locally or report issues, refer to Elastic style guide for Vale. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed commit message
fix: make Azure billing usage and forecast windows configurable
The azure/billing metricset always queried a hardcoded window: exactly the
previous full UTC day for usage, and reference-2d..+30d for forecast. Azure
Cost Management data can change for up to 72 hours after a billing period
closes, but the metricset never re-queried a date it had already collected,
so late cost corrections were never ingested.
Add two duration config options to the shared azure.Config:
usageIntervalFrom and forecastIntervalFrom now take the window as a
parameter; defaults reproduce the previous behaviour exactly, so existing
deployments are unaffected. Operators can set billing_usage_lookback: 72h
to re-ingest Azure's late corrections.
Checklist
stresstest.shscript to run them under stress conditions and race detector to verify their stability../changelog/fragmentsusing the changelog tool.Disruptive User Impact
How to test this PR locally
Ran the
azurebillingmetricset against a live Azure subscription withbilling_usage_lookback: 72h, publishing to a local Elasticsearch, and confirmedthat usage data is now collected for the whole lookback window instead of just the
previous day.
The metricset logs show the widened usage window (start moved back to
-72h, endunchanged at the previous full day):
Verified in Elasticsearch that usage documents span three full days. The
azure.billing.usage_startfilter isolates usage docs (excludes the forward-lookingforecast events), and a daily
date_histogramonazure.billing.usage_datereturnsone bucket per collected day:
Request / Response
Request:
Response:
{ "took": 8, "timed_out": false, "_shards": { "total": 1, "successful": 1, "skipped": 0, "failed": 0 }, "hits": { "total": { "value": 839, "relation": "eq" }, "max_score": null, "hits": [] }, "aggregations": { "days": { "buckets": [ { "key_as_string": "2026-07-19", "key": 1784419200000, "doc_count": 277 }, { "key_as_string": "2026-07-20", "key": 1784505600000, "doc_count": 289 }, { "key_as_string": "2026-07-21", "key": 1784592000000, "doc_count": 273 } ] } } }Three
usage_datebuckets (2026-07-19,2026-07-20,2026-07-21) confirm the72h window re-queried three full days. With the default
24hlookback the samequery returns a single bucket (
2026-07-21), matching the previous behaviour.A reviewer can reproduce this with a minimal config:
Related issues
Use cases
Screenshots
Logs