elastic / elastic/beats

AWS billing module failing with `period` lower than 24h

Open
#32,627 9 comments 1 reaction 0 assignees View on GitHub
bug Team:Integrations
Dominant language
Go
Stars
12.7k
Forks
5k
Avg merge
2d 1h
Merged PRs (30d)
370

Description

See: https://discuss.elastic.co/t/fleet-aws-billing-integration/311138/6

it's still present in with the aws sdk v2 upgrade
this the error returned by GetCostAndUsageRequest call: `Start date (and hour) should be before end date (and hour)`

when we generate the start and end time we remove from now the period setting duration, and finally truncate the time part. anything less than 24h will result in the same date
(https://github.com/elastic/beats/blob/7a469fd6096ac1a4adfd45682c381daa2e0eb139/x-pack/metricbeat/module/aws/billing/billing.go#L375-L381, https://github.com/elastic/beats/blob/7a469fd6096ac1a4adfd45682c381daa2e0eb139/x-pack/metricbeat/module/aws/billing/billing.go#L46)

`period` can accept any valid `time.Duration`

Tasks:
- [ ] Add config validation for minimum `period` of 1 day in billings data stream. If possible we should validate a granularity of 1 day too.
- [ ] Fix truncation of `period` for values of less than 24h. Even though config is validated, we should still code defensively so that periods lower than the minimum are capped to the minimum value, or at the very least do not cause any issues. Unit tests are required.
- [ ] Update the documentation in metricbeat so the granularity and minimum allowed value is clear.

Contributor guide

Open the contributing guide

Research direction

Start in x-pack/metricbeat/module/aws/billing/billing.go, especially the period configuration and the time calculation around lines 375-381; reproduce how a duration under 24 hours produces identical truncated dates. Add minimum-period and granularity validation, preserve defensive handling and unit coverage, then update the Metricbeat billing documentation so the accepted minimum and granularity are explicit.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, go
Domain
cloud, documentation
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.