Wazuh agent buffer: client_buffer, EPS and lost events
How the Wazuh agent buffer works, what the client_buffer limits and alerts 202-205 mean, and how to judge the risk of lost events before the manager.
An agent can lose events before they reach the Wazuh manager. In that situation the analysis on the manager side will not show the events that the agent failed to send.
Where the loss happens
The agent collects data from log files, command output and scans, then splits it into events. The client_buffer buffer controls the flow of these events from the agent to the manager. When the agent produces them faster than it can send them, the queue holds the excess for a while. This limits sudden load on the network and the manager, but it does not create unlimited retention.
The agent queue works like a leaky bucket. It accepts events up to a set capacity, then passes them on at a rate limited by EPS, the number of events per second. A short spike can be absorbed by free space. A long-lasting surplus will fill the queue. Once it is full, new events are dropped until space frees up.
This loss point lies before the manager. So the lack of a matching alert in the manager’s analysis does not rule out a problem on the agent. For losses that already happen on the manager side, the separate write-up analysis of drops in analysisd helps.
The documentation lists several situations that can make the queue grow fast. Real-time monitoring of a directory where files change constantly can generate an event on every change. A special case is a directory that contains files Wazuh itself updates while generating events, for example /var/ossec/logs/. Such a layout can create an event loop.
Another example concerns the Windows Filtering Platform. With the Windows firewall event with ID 5156 enabled, every allowed outbound network connection can generate an event. If the agent monitors all Windows security logs, the connection between the agent and the manager can itself generate further events of this type. The documentation also describes applications that retry a failed task without rate limiting and write another log entry on every failed attempt.
Three client_buffer options
The block belongs to the agent configuration in ossec.conf. It covers the mechanism switch, the queue capacity and the flow limit to the manager.
| Option | Meaning | Default | Allowed values |
|---|---|---|---|
disabled | Disables or enables the agent buffer | no | yes, no |
queue_size | Buffer capacity in events | 5000 | from 1 to 100000 |
events_per_second | Maximum number of events sent to the manager per second | 500 | from 1 to 1000 |
The example shows the default values, not a recommendation for a specific agent.
<client_buffer>
<!-- Agent buffer options -->
<disabled>no</disabled>
<queue_size>5000</queue_size>
<events_per_second>500</events_per_second>
</client_buffer>
disabled set to yes sends events without overload control. The documentation warns that in large environments this can overload the manager and the network, and then lead to their failure. It is not a way to enlarge the buffer. It removes the mechanism that limits traffic.
What happens after the queue fills up
The documentation example shows the behavior with a full buffer and a limit of 500 EPS. If 1000 events arrive in one second, 500 are stored and 500 are dropped.
The example shows the consequence of combining a full queue with events arriving faster than the limit on sending them. You have to separate short peaks from a steady rate. A larger queue_size gives more room for buffering. A higher events_per_second drains the queue faster, but affects the send rate from the agent to the manager.
Statuses and manager rules
The manager reports queue states through rules 202, 203, 204 and 205. The warning appears by default at 90% occupancy. A return to the normal state is reported when it drops to 70% or lower, if a warning or a more serious state occurred earlier.
| Rule | State | Meaning |
|---|---|---|
202 | Warning | Occupancy reached the default threshold of 90%; the documentation notes that events are not dropped yet |
203 | Full buffer | Capacity reached 100%; new events are dropped when there is no free space |
204 | Flooding | The buffer stayed above the warning threshold for the agent.tolerance time; the agent drops events and may not return to normal on its own |
205 | Normal state | After an earlier warning or a more serious state, occupancy returned to the normal threshold, by default 70% or less |
When the buffer is full, a counter starts and is compared with agent.tolerance from /var/ossec/etc/internal_options.conf. If usage drops below the warning threshold before that time passes, the manager will not receive a flooding alert. If the buffer stays above the threshold until the tolerance expires, the manager reports flooding.
The warning and normal-state thresholds and the tolerance time belong to the advanced buffer options in the agent’s /var/ossec/etc/internal_options.conf.
EPS limits and central configuration
The client_buffer parameters can be set locally in the agent’s ossec.conf or centrally in agent.conf. Central configuration overrides the agent’s local configuration.
agent.min_eps in the agent’s /var/ossec/etc/internal_options.conf sets the minimum EPS the agent can transmit. The documentation states that this value overrides the EPS limit configured centrally through agent.conf.
There are also internal limits that apply to event production by specific modules. logcollector.max_lines limits the number of lines logcollector reads from one file in one read cycle. wazuh_modules.max_eps regulates the rate at which Syscollector scan results are sent. The documentation describes them as advanced internal configuration options and advises caution when changing them.
Module limits apply to the creation or reading of data, while the agent buffer applies to passing events on to the manager. When diagnosing, first establish which stage hits its limit, instead of raising all values at once.
The local agent configuration file depends on the system. The documentation gives /var/ossec/etc/ossec.conf for Linux and Unix, C:\Program Files (x86)\ossec-agent\ossec.conf for Windows and /Library/Ossec/etc/ossec.conf for macOS.
After changing the agent’s local client_buffer block you have to restart it with administrator privileges. The documentation gives the command for each system:
# Linux
systemctl restart wazuh-agent
# Windows
Restart-Service -Name wazuh
# macOS
/Library/Ossec/bin/wazuh-control restart
What wazuh-agentd.state shows
The agent statistics file shows part of the current state.
| Field | What the documentation assigns to the field | Limit on interpretation |
|---|---|---|
msg_buffer | Number of events currently in the buffer | Empty when the anti-flooding mechanism is disabled |
msg_count | Number of events generated by the agent | Does not give the number of lost events on its own |
msg_sent | Number of messages sent, including events and control messages | Not a counter of events only |
By default the file updates every 5 seconds. You can change the interval with the agent.state_interval setting in the internal configuration.
Checklist for sizing and verification
Start by establishing whether the agent uses local or central configuration. Then check the current values of queue_size, events_per_second and disabled, and whether agent.min_eps overrides the central limit. Take the module limits into account if logcollector or Syscollector may be the source of the excessive rate.
When choosing values, relate the buffer capacity to the number of events the agent may generate, and take the rate at which they are sent into account. Do not assume that increasing the capacity alone will solve a steady rate surplus.
When verifying the state, put alerts 202 to 205 next to msg_buffer, msg_count and msg_sent. Judge whether occupancy only crossed the warning threshold, reached 100%, or persisted for the agent.tolerance time. After a change, watch the following statistics samples and the recovery status.
What the documentation does not specify
The documentation gives no default value of agent.tolerance, no names of the options that set the 90% and 70% thresholds, and no counter of lost events in wazuh-agentd.state. It also does not describe how to confirm on the agent which configuration, local or central, is active. Comparing msg_count with msg_sent does not give an exact number of losses, because msg_sent also includes control messages, and the state file shows only periodic samples. It also does not describe a historical API for reading buffer statistics or the exact time relation of the counters in this file.