Skip to content

x-pack/filebeat/input/cel: add support for dynamic rate limit setting#46953

Merged
efd6 merged 4 commits intoelastic:mainfrom
efd6:mito1230
Oct 9, 2025
Merged

x-pack/filebeat/input/cel: add support for dynamic rate limit setting#46953
efd6 merged 4 commits intoelastic:mainfrom
efd6:mito1230

Conversation

@efd6
Copy link
Contributor

@efd6 efd6 commented Oct 6, 2025

Proposed commit message

This adds support for directly setting the mito runtime's limiter's limit
and burst before return from the CEL evaluation. This is important for
cases where the CEL program is making multiple requests to a set of
related endpoints that share a rate limit budget before the CEL program
returns as it enables the program/runtime to conform to the API's limit
policies without returning from the CEL program.

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

Author's Checklist

  • [ ]

How to test this PR locally

Related issues

Use cases

Screenshots

Logs

efd6 added 4 commits October 7, 2025 08:39
This adds support for directly setting the mito runtime's limiter's limit
and burst before return from the CEL evaluation. This is important for
cases where the CEL program is making multiple requests to a set of
related endpoints that share a rate limit budget before the CEL program
returns as it enables the program/runtime to conform to the API's limit
policies without returning from the CEL program.
@efd6 efd6 self-assigned this Oct 6, 2025
@efd6 efd6 added enhancement Filebeat Filebeat backport-skip Skip notification from the automated backport with mergify Team:Security-Service Integrations Security Service Integrations Team labels Oct 6, 2025
@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 Oct 6, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Oct 6, 2025

🤖 GitHub comments

Expand to view the GitHub comments

Just comment with:

  • run docs-build : Re-trigger the docs validation. (use unformatted text in the comment!)

@github-actions
Copy link
Contributor

github-actions bot commented Oct 6, 2025

🔍 Preview links for changed docs

Comment on lines +1120 to +1126
lib.LimitWithApply(limitPolicies, func(m map[string]any, h http.Header) map[string]any {
waitUntil := handleRateLimit(log, m, h, limit)
if !waitUntil.IsZero() {
log.Debugw("rate limit waiting", "reset", waitUntil)
}
return m
}),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could refine the logic here; adding a couple of magic fields (bikeshed: no_apply and no_wait) to the header to signal to the callback that application of the limit result should not be done or that the wait should not be slept (we currently don't sleep, but with that we would add in a conditional sleep). I'm not sure that this complication is worth it, but putting it out there for comment.

@efd6
Copy link
Contributor Author

efd6 commented Oct 7, 2025

/test

1 similar comment
@efd6
Copy link
Contributor Author

efd6 commented Oct 7, 2025

/test

@efd6 efd6 marked this pull request as ready for review October 7, 2025 23:20
@efd6 efd6 requested review from a team as code owners October 7, 2025 23:20
@elasticmachine
Copy link
Contributor

Pinging @elastic/security-service-integrations (Team:Security-Service Integrations)

@efd6 efd6 requested a review from andrewkroh October 7, 2025 23:20
@efd6 efd6 merged commit 1a0d5cd into elastic:main Oct 9, 2025
222 of 225 checks passed
andrzej-stencel pushed a commit to andrzej-stencel/beats that referenced this pull request Dec 1, 2025
…elastic#46953)

This adds support for directly setting the mito runtime's limiter's limit
and burst before return from the CEL evaluation. This is important for
cases where the CEL program is making multiple requests to a set of
related endpoints that share a rate limit budget before the CEL program
returns as it enables the program/runtime to conform to the API's limit
policies without returning from the CEL program.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-skip Skip notification from the automated backport with mergify enhancement Filebeat Filebeat Team:Security-Service Integrations Security Service Integrations Team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

x-pack/filebeat/input/cel: add support for immediate HTTP request rate limit updating

4 participants