Skip to content

feat: Introduce lastSync start position to AWS CloudWatch input backed by state registry#43251

Merged
Kavindu-Dodan merged 5 commits intoelastic:mainfrom
Kavindu-Dodan:feat/registry-for-cloudwatch
Jun 10, 2025
Merged

feat: Introduce lastSync start position to AWS CloudWatch input backed by state registry#43251
Kavindu-Dodan merged 5 commits intoelastic:mainfrom
Kavindu-Dodan:feat/registry-for-cloudwatch

Conversation

@Kavindu-Dodan
Copy link
Contributor

@Kavindu-Dodan Kavindu-Dodan commented Mar 12, 2025

Proposed commit message

Introduce lastSync option to AWS CloudWatch input's start_position configuration. This feature utilizes the state registry, which with this update stores the last successful sync timestamp under the last_sync_epoch key.

start_position configuration by default uses beginning option. This can cause data duplications when restarting filebeats or migrating it to a newer version. Users can avoid such data duplocates by utilizing lastSync option for the start_position configuration while targeting beats to use the same registry location.

Acknowledgement backed state updates

After the initial review, the need for acknowledgments prior to the state registry update was identified thanks to this remark - #43251 (comment)

Based on this feedback, I have implemented the state registry update with following component interactions,

image

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works
  • I have added an entry in CHANGELOG.next.asciidoc or CHANGELOG-developer.next.asciidoc.

Disruptive User Impact

None - start_position by default use beginning. So this new option is an opt-in feature.

Screenshots

Example filebeat.yml configuration,

image

Example state entries with last sync timestamp updates,

image

@Kavindu-Dodan Kavindu-Dodan added Team:obs-ds-hosted-services Label for the Observability Hosted Services team backport-active-all Automated backport with mergify to all the active branches labels Mar 12, 2025
@Kavindu-Dodan Kavindu-Dodan self-assigned this Mar 12, 2025
@Kavindu-Dodan Kavindu-Dodan requested review from a team as code owners March 12, 2025 20:56
@elasticmachine
Copy link
Contributor

Pinging @elastic/obs-ds-hosted-services (Team:obs-ds-hosted-services)

@botelastic botelastic bot added needs_team Indicates that the issue/PR needs a Team:* label and removed needs_team Indicates that the issue/PR needs a Team:* label labels Mar 12, 2025
@Kavindu-Dodan Kavindu-Dodan changed the title feat: Introduce lastSync start position to AWS CloudWatch input backed by registry Mar 12, 2025
@Kavindu-Dodan Kavindu-Dodan force-pushed the feat/registry-for-cloudwatch branch 2 times, most recently from 91bfda9 to fecf38d Compare March 12, 2025 21:26
Copy link
Contributor

@MichaelKatsoulis MichaelKatsoulis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.
Very good work! I have only left some small comments.

@Kavindu-Dodan Kavindu-Dodan force-pushed the feat/registry-for-cloudwatch branch from 86c2166 to 1cdaf6a Compare March 13, 2025 14:27
@pierrehilbert pierrehilbert added the Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team label Mar 13, 2025
@elasticmachine
Copy link
Contributor

Pinging @elastic/elastic-agent-data-plane (Team:Elastic-Agent-Data-Plane)

@pierrehilbert pierrehilbert requested a review from faec March 13, 2025 15:53
@Kavindu-Dodan Kavindu-Dodan force-pushed the feat/registry-for-cloudwatch branch 2 times, most recently from 6507477 to 6eefa92 Compare March 13, 2025 22:02
@Kavindu-Dodan Kavindu-Dodan requested a review from faec March 13, 2025 22:07
Copy link
Contributor

@VihasMakwana VihasMakwana left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, @MichaelKatsoulis has already given his approval and code looks good.

@Kavindu-Dodan Kavindu-Dodan force-pushed the feat/registry-for-cloudwatch branch from 6eefa92 to d064c6e Compare March 17, 2025 17:29
@Kavindu-Dodan Kavindu-Dodan requested a review from a team March 17, 2025 19:48
@rdner rdner removed their request for review March 19, 2025 12:44
@Kavindu-Dodan Kavindu-Dodan marked this pull request as draft March 21, 2025 21:50
@Kavindu-Dodan Kavindu-Dodan requested a review from faec June 3, 2025 19:34
Copy link
Contributor

@faec faec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, looks good but one last very small but important change

@Kavindu-Dodan Kavindu-Dodan requested a review from faec June 6, 2025 13:39
Copy link
Contributor

@faec faec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for all your work on this! Approved.

@Kavindu-Dodan
Copy link
Contributor Author

Thanks for all your work on this! Approved.

Thank you @faec for the detailed review 🙏

@Kavindu-Dodan
Copy link
Contributor Author

@elastic/beats-tech-leads - can I get a final approval :)

@Kavindu-Dodan Kavindu-Dodan added backport-active-all Automated backport with mergify to all the active branches and removed backport-active-all Automated backport with mergify to all the active branches labels Jun 6, 2025
Copy link
Member

@ebeahan ebeahan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Kavindu-Dodan question about the backporting label. If this is a new feature, should we only target landing in 8.19 & 9.1 instead of backport-active-all?

@Kavindu-Dodan
Copy link
Contributor Author

Kavindu-Dodan commented Jun 9, 2025

@Kavindu-Dodan question about the backporting label. If this is a new feature, should we only target landing in 8.19 & 9.1 instead of backport-active-all?

Good point, plan was to merge only the necessary 9.1.x & 8.19.x and reject others. But I think that adds confusion so I will add only the needed :)

update - I have updated the labels :)

@Kavindu-Dodan Kavindu-Dodan added backport-8.19 Automated backport to the 8.19 branch and removed backport-active-all Automated backport with mergify to all the active branches labels Jun 9, 2025
@Kavindu-Dodan Kavindu-Dodan requested a review from ebeahan June 9, 2025 15:12
Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>

finalize AWS CW lastSync start position usage

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>

update changelog next

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>

review changes

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>

review changes - improve state store id, fix timestamp and return nil for error

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>

documentation update with md migration

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>

# Conflicts:
#	x-pack/filebeat/input/awscloudwatch/config.go
Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>
Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>
…n handling

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>
Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>
@Kavindu-Dodan Kavindu-Dodan force-pushed the feat/registry-for-cloudwatch branch from 5782ba9 to 4ab81a4 Compare June 10, 2025 13:36
@elastic elastic deleted a comment from mergify bot Jun 10, 2025
@Kavindu-Dodan Kavindu-Dodan requested a review from a team June 10, 2025 15:44
@Kavindu-Dodan Kavindu-Dodan merged commit 42e50cf into elastic:main Jun 10, 2025
203 checks passed
mergify bot pushed a commit that referenced this pull request Jun 10, 2025
…d by state registry (#43251)

* add state registry support for cloudwatch input

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>

finalize AWS CW lastSync start position usage

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>

update changelog next

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>

review changes

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>

review changes - improve state store id, fix timestamp and return nil for error

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>

documentation update with md migration

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>

# Conflicts:
#	x-pack/filebeat/input/awscloudwatch/config.go

* review change: use ackers for confirmed delivery prior to saving state

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>

* review: documentation updates

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>

* review changes : ctx handling, shutdown improvement and race condition handling

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>

* review : fix ctx condition

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>

---------

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>
(cherry picked from commit 42e50cf)

# Conflicts:
#	docs/reference/filebeat/filebeat-input-aws-cloudwatch.md
Kavindu-Dodan added a commit that referenced this pull request Jun 11, 2025
…S CloudWatch input backed by state registry (#44736)

* feat: Introduce lastSync start position to AWS CloudWatch input backed by state registry (#43251)

* add state registry support for cloudwatch input

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>

finalize AWS CW lastSync start position usage

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>

update changelog next

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>

review changes

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>

review changes - improve state store id, fix timestamp and return nil for error

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>

documentation update with md migration

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>

# Conflicts:
#	x-pack/filebeat/input/awscloudwatch/config.go

* review change: use ackers for confirmed delivery prior to saving state

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>

* review: documentation updates

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>

* review changes : ctx handling, shutdown improvement and race condition handling

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>

* review : fix ctx condition

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>

---------

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>
(cherry picked from commit 42e50cf)

# Conflicts:
#	docs/reference/filebeat/filebeat-input-aws-cloudwatch.md

* Update CHANGELOG.next.asciidoc

* update CloudWatch documentation for backport

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>

---------

Signed-off-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>
Co-authored-by: Kavindu Dodanduwa <Kavindu-Dodan@users.noreply.github.com>
Co-authored-by: Kavindu Dodanduwa <kavindu.dodanduwa@elastic.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-8.19 Automated backport to the 8.19 branch Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team Team:obs-ds-hosted-services Label for the Observability Hosted Services team

10 participants