How to configure log collection buffers
Vector agent buffers and delivery to the platform log storage.
The shturval-log-collector agent on each node writes logs to its Vector disk buffer before sending them to the platform. Logs are also stored in the container log directory on the node disk and in VictoriaLogs.
| Location | Where to look | What limits the buffer |
|---|---|---|
| Container log files | /var/log/pods on the node disk | A node partition or quota. How to check the disk and set a quota: Container logs fill the node disk |
| Agent buffer | node directory /var/lib/vector. The data volume mounts it into the agent container as /vector-data-dir | The sum of this agent’s buffer sizes. About 1.25 GiB if all five are full |
| Platform storage | VictoriaLogs in the management cluster | Retention in VLSingle |
Buffer size and the way logs are sent are set by default. You may need to change the defaults when:
- the receiverThe VictoriaLogs instance in the management cluster. After the buffer, the Vector agent sends logs to it for storage. is unavailable and the buffer is already full;
- after VictoriaLogs recovers, accumulated logs from several nodes arrive at once and overload VictoriaLogs;
- you need a buffer larger than 256 MiB per receiverOne of the five platform log receivers (platform sinks): auditd, journald, k8s_audit, k8s_events, or k8s_logs. Each has its own disk buffer.. Before that, limit
/var/lib/vectoron the node: give it a separate disk partition or a disk quota, so a larger buffer does not fill the whole node disk.
To change how long logs are kept, see How to set up log rotation. To turn log sending off, see How to manage sending logs in the platform. To configure a buffer for external storage, see How to set up log collection and redirection.
Do not edit preconfigured system ClusterVectorPipeline resources by hand: that can break log collection, aggregation, and delivery. Change buffer parameters by applying a ShturvalServicePatch (SSP).
Buffer parameters
By default, parameters are set for each buffer of all receivers (sinks): auditd, journald, k8s_audit, k8s_events, or k8s_logs:
| Parameter | Default | Available values | Description |
|---|---|---|---|
buffer.type | disk | memoryEvents are kept in process memory and are lost when the agent restarts. These receivers do not use it., diskEvents are written to the node disk and kept when the agent restarts. | The build uses disk: the buffer is kept when the agent restarts |
buffer.max_events | not set | event count | Only for an in-memory buffer. Applies when type: memory. For such a buffer Vector defaults to about 500 events. With a disk buffer, size is set by buffer.max_size |
buffer.max_size | 268435488 bytes, about 256 MiB | bytes | Size of one buffer. For a disk buffer this is the smallest value Vector allows. Applies when type: disk |
buffer.when_full | block | blockWhen the buffer is full, the agent waits for free space and does not drop new events., drop_newestWhen the buffer is full, the agent drops the new event and keeps reading. Those lines will not reach storage. Enable this only when that loss is acceptable. | Behavior when the buffer is full. Vector has no “drop the oldest” mode (drop_oldest) and no ring buffer. A chain of several buffers with an intermediate overflow mode is not used: Vector does not consider this mode ready for production and does not guarantee event order. |
request.concurrency | adaptive | adaptiveThe number of concurrent requests to VictoriaLogs adapts to its responses. or a numberA fixed number turns adaptation off for this receiver. Set it only when adaptive does not fit. | Maximum number of concurrent requests the sink sends |
request.rate_limit_duration_secs | not set | seconds | The period, in seconds, during which the sink sends no more HTTP requests than the request.rate_limit_num limit. The number of concurrent requests is set by request.concurrency |
request.rate_limit_num | not set | request count | How many HTTP requests the sink sends during the request.rate_limit_duration_secs period. Until both parameters are set, Vector does not limit request frequency. The limit applies both with concurrency: adaptive and with a fixed number |
kubernetes_logs.rotate_wait_secs | 60 | seconds | Pause before closing a container log file that kubelet has already deleted. It is not related to buffer size. With when_full: block and a full buffer, the read loop does not reach this check: descriptors in /var/log/pods stay open until there is space in the buffer. With drop_newest the source is not blocked; files are closed after rotate_wait_secs. |
The sum of the five default buffers is about 1.25 GiB per node. /var/lib/vector needs at least 1.25 GiB free. The buffer has no separate retention period. The agent deletes a buffer segment after it has fully sent it to the receiver. Writes to disk happen about every 500 ms. If writing the buffer to disk fails, the Vector process stops.
Increase buffer.max_size only when /var/lib/vector is already on a separate partition or quota. Otherwise a larger buffer fills the node disk sooner.
The full parameter list is in the Vector buffering model.
If the buffer is full
By default the internal metrics source (spec.agent.internalMetrics on the Vector resource) is disabled. When the source is enabled, fullness can be seen from buffer metrics:
| Metric | What it shows |
|---|---|
vector_buffer_byte_size | how many bytes the buffer occupies now |
vector_buffer_events | how many events are in the buffer |
vector_buffer_discarded_events_total | how many events were discarded. It grows in drop_newest mode |
Without these metrics, buffer fullness can be judged from the node disk: the /var/lib/vector and /var/log/pods directories.
You can set when_full separately for each receiver. To change when_full on one buffer object:
- Prepare a
ShturvalServicePatchmanifest forshturval-log-collector. The module must be in Auto mode. In Manual mode the SSP may not apply. The difference between the modes is on Collection and processing of logs (ClusterVectorPipeline). - Load the manifest in the cluster where the module runs, through Importing manifests: Administration → Cluster Actions.
- Wait until it is applied. On the local log collection module page the service status changes to
Patched, and the SSP appears on the Applied ShturvalServicePatch tab.
Do not set request.concurrency to a number in the same object if you need to keep adaptive. A number turns adaptation off for this receiver.
ShturvalServicePatch example with block mode
The default mode is block. With block, the sink waits for space in the buffer and applies backpressure to the source. New events are not dropped. While the buffer is full, the kubernetes_logs read loop does not reach closing of files that are already deleted. kubelet deletes a rotated file, and the agent still holds it open and does not get to close it. Space on the node disk is not freed. If /var/log/pods is not limited, the node disk fills up: containers cannot write files, and new pods do not start. A full buffer on the other four receivers also stops reading of their own source, but /var/log/pods is filled by container log collection.
To keep events again after drop_newest, set block back. Example for k8s_logs. For auditd, journald, k8s_audit, and k8s_events set it the same way, inside their own platform_logs_sink.
apiVersion: ops.shturval.tech/v1beta2
kind: ShturvalServicePatch
metadata:
name: shturval-log-collector-buffer-block
spec:
shturvalServiceConfigName: shturval-log-collector
customvalues:
shturval:
k8s_logs:
platform_logs_sink:
buffer:
when_full: block
While a buffer in block mode is full, the 60-second pause does not start. The agent closes the deleted file only when there is space in the buffer or the Vector process exits.
ShturvalServicePatch example with drop_newest mode
Enable drop_newest only for receivers where losing new events is acceptable. While the buffer is completely full, the agent drops the new event and keeps reading the source. For container logs, a deleted file is closed after the 60-second pause, and space on the node disk is freed. Logs that did not enter the buffer will not appear in platform storage.
ShturvalServicePatch example with drop_newest for all receivers.
apiVersion: ops.shturval.tech/v1beta2
kind: ShturvalServicePatch
metadata:
name: shturval-log-collector-buffer-drop-newest
spec:
shturvalServiceConfigName: shturval-log-collector
customvalues:
shturval:
auditd:
platform_logs_sink:
buffer:
when_full: drop_newest
journald:
platform_logs_sink:
buffer:
when_full: drop_newest
k8s_audit:
platform_logs_sink:
buffer:
when_full: drop_newest
k8s_events:
platform_logs_sink:
buffer:
when_full: drop_newest
k8s_logs:
platform_logs_sink:
buffer:
when_full: drop_newest
Discarded events show up in the Vector metric vector_buffer_discarded_events_total if the agent has internal metrics enabled.
Request concurrency
By default, for all sinks the number of concurrent requests adapts to responses: request.concurrency: adaptive. When adaptation does not fit a particular sink, you can change it by applying an SSP for shturval-log-collector. The limit of concurrent HTTP requests to the sink starts from a lower value. When requests succeed without a growth in response latency, the limit increases. When the sink rejects requests because of load, for example HTTP 429, or when latency rises noticeably, the limit decreases, but it is not set below 1.
After the sink recovers, a preset maximum of parallel requests is not applied immediately. Accumulated events leave gradually. While sinks are idle, disk is not freed: the buffer fills up to max_size, and then the when_full mode policy applies.
A fixed number, for example request.concurrency: 10, turns adaptation off for this sink.
By default request.rate_limit_duration_secs and request.rate_limit_num are not set. The window and the number of requests in it set how often the sink sends HTTP requests, separately from the number of concurrent requests. According to the Vector HTTP sink documentation, this limit applies both with concurrency: adaptive and with a fixed number. The example from the documentation is a 1 second window and 10 requests, that is no more than 10 requests per second.
How to check the node disk, enable a project quota, and align kubelet rotation is described in Container logs fill the node disk.