Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Event Batching Configurable #306

Closed
Tracked by #241
vikman90 opened this issue Nov 14, 2024 · 5 comments · Fixed by #377
Closed
Tracked by #241

Make Event Batching Configurable #306

vikman90 opened this issue Nov 14, 2024 · 5 comments · Fixed by #377
Assignees
Labels
level/task Task issue module/agent mvp Minimum Viable Product refinement type/enhancement Enhancement issue

Comments

@vikman90
Copy link
Member

vikman90 commented Nov 14, 2024

Parent Issue: #241

Description

Currently, the Wazuh Agent sends batches of messages from its queue to the server every second. We propose making the batching process configurable to allow greater flexibility.

The agent should send a batch of messages under the first condition that occurs:

  1. If batch_interval has elapsed since the last batch and there are messages in the queue.
  2. If the accumulated size of messages in the queue reaches batch_size.

This design ensures:

  • Messages do not stay in the queue for longer than batch_interval seconds.
  • Requests do not exceed a specified maximum size.
  • The queue drains at a controlled rate, preventing overflow unless external limitations apply.

Proposed Configuration Options

The following parameters can be added to agent.yml:

events:
  batch_interval: "10s"  # Maximum time between batch sends (default: 10 seconds).
  batch_size: "1000"       # Maximum number of messages in a batch (default: 1000).

Parameter Details

  • batch_interval:

    • Specifies the maximum time between batch sends.
    • Accepts values with time units: "500ms", "10s", "1m", "1h".
    • Valid range: "1s" to "1h".
  • batch_size:

    • Specifies the maximum number of messages in a batch.
    • Valid range: "1000" to "1000000".
@vikman90 vikman90 added level/task Task issue type/enhancement Enhancement issue module/agent mvp Minimum Viable Product refinement labels Nov 14, 2024
@wazuhci wazuhci moved this to Backlog in Release 5.0.0 Nov 14, 2024
@vikman90 vikman90 self-assigned this Nov 18, 2024
@wazuhci wazuhci moved this from Backlog to In progress in Release 5.0.0 Nov 18, 2024
@vikman90
Copy link
Member Author

vikman90 commented Nov 18, 2024

Work update

November 18

@wazuhci wazuhci moved this from In progress to Blocked in Release 5.0.0 Nov 20, 2024
@wazuhci wazuhci moved this from Blocked to On hold in Release 5.0.0 Nov 21, 2024
@wazuhci wazuhci moved this from On hold to In progress in Release 5.0.0 Nov 25, 2024
@jr0me
Copy link
Member

jr0me commented Nov 26, 2024

Update

Checked out branche and rebased to latest master. Fixed tests related to the message queue get and pop messages functions.

@wazuhci wazuhci moved this from In progress to On hold in Release 5.0.0 Nov 28, 2024
@wazuhci wazuhci moved this from On hold to In progress in Release 5.0.0 Nov 28, 2024
@jr0me
Copy link
Member

jr0me commented Nov 29, 2024

Update

Picked up the work after having it paused by other tasks.

Rebased again and solved conflicts.

There are new variables for setting the batch size and interval.

The multitype queue already supported having a timeout interval, the mentioned variables will be used as the multitype queue timeout interval. The mechanism to either wait for the batch to be complete or the timeout to have passed is in place.

What is missing now is a way to communicate how many messages have been used from the queue, so they can be popped at a latter staged if they were recived by the manager. Currently the queue doesn't enforce its invariant in any way, so how many messages are retrieved and how many are popped needs to match and this value has to be persisted throughout.

@jr0me
Copy link
Member

jr0me commented Nov 29, 2024

Update

The number of messages retrieved is now shared between get and pop calls. Needs testing.

Proposed configuration options need to be renamed.

@jr0me jr0me linked a pull request Dec 2, 2024 that will close this issue
3 tasks
@jr0me
Copy link
Member

jr0me commented Dec 3, 2024

Update

Created PR for the issue. Waiting review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
level/task Task issue module/agent mvp Minimum Viable Product refinement type/enhancement Enhancement issue
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants