Repository navigation
feat(chart): hold container logs back instead of dropping them when ClickHouse is down - #678
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces persistent log position tracking for the nudgebee-agent daemonset to ensure at-least-once log delivery. It mounts a host path volume to store log positions and configures a dedicated clickhouse/logs exporter in the OpenTelemetry Collector with custom queueing and retry settings to prevent log loss during ClickHouse outages. Feedback on the changes highlights a critical configuration issue where the batching configuration is incorrectly nested inside sending_queue instead of being a sibling batcher block, which would cause startup failure. Additionally, the queue_size is configured too high because sizer: items counts batches rather than individual records, posing an OOM risk.
blue4209211
left a comment
There was a problem hiding this comment.
The design is right: a dedicated clickhouse/logs exporter with unbounded retry and a blocking queue, no batch processor in the logs pipeline, and positions on a per-release hostPath only in logs.collection=node-agent mode. I checked that both the env var and the mount sit inside that branch, so other modes' pod spec is unchanged. The loss numbers in the test table are convincing. Your reply on the sending_queue.batch form matches the 0.157 exporterhelper README.
Before merge:
- Release order. This needs the node-agent release that reads
LOGS_POSITIONS_FILE(nudgebee/node-agent#407, still open), plus thenodeAgent.image.tagbump in this PR. Until then it shouldn't merge, since an older node-agent doesn't retry when the collector holds a request. - Chart version. #677 takes 0.1.31 and this PR 0.1.32. Merge in that order, or rebase whichever lands second.
Known limits, fine as documented, worth tracking:
- The queue is in memory, so records queued while ClickHouse is down are lost if the collector itself restarts or is OOM-killed. A
file_storage-backed persistent queue is the natural follow-up. - Outages longer than about one log file per container (
containerLogMaxSize) still lose the rotated-away files. - With #677, a disk at 95% holds logs indefinitely while traces and metrics are dropped after 300 s. That's the right trade-off, but worth stating in the chart docs.
- Nit: the per-release hostPath directory stays on nodes after uninstall.
|
@blue4209211 thanks. Agreed on all points.
Evidence:
|
d84c504 to
f6f3a61
Compare
|
Chart version: please drop the Other points:
|
…lickHouse is down With logs.collection=node-agent, container logs were lost whenever the node-agent, the collector or ClickHouse restarted. This is the chart half of at-least-once delivery; the node-agent half resumes from saved positions and retries until the collector accepts. - node-agent (logs.collection=node-agent only): LOGS_POSITIONS_FILE on a per-release hostPath under /var/lib/nudgebee-node-agent, so a restarted node-agent resumes where delivery stopped. Other modes keep the same pod spec. - Collector: the logs pipeline gets its own exporter, clickhouse/logs, with the connection settings of `clickhouse` (templated, so overrides carry over). It retries without a time limit and batches from a 100000-record queue that blocks the receiver when full, and the logs pipeline drops the batch processor, which accepted records and dropped them after 300 s of failed retries. A ClickHouse outage now makes node-agents keep unsent lines in the node's log files. Traces and metrics keep the shared exporter. Merge with the node-agent release that reads LOGS_POSITIONS_FILE (nodeAgent.image.tag); older node-agents ignore it.
f6f3a61 to
97926b8
Compare
|
Thanks. All four addressed in the amended commit (97926b8):
|
Summary
With
logs.collection=node-agent, container logs were lost whenever the node-agent, the collector or ClickHouse restarted. This is the chart half of at-least-once delivery. The node-agent half (nudgebee/node-agent#407) saves its position in each file and retries until the collector accepts.logs.collection=node-agentonly):LOGS_POSITIONS_FILEon a per-release hostPath under/var/lib/nudgebee-node-agent, so a restarted node-agent resumes where delivery stopped. Other modes keep the same pod spec.clickhouse/logs. Its connection settings are templated fromclickhouse, so overrides carry over.batchprocessor. That processor accepted records and then dropped them after 300 s of failed retries.Merge after the node-agent release that reads
LOGS_POSITIONS_FILE, withnodeAgent.image.tagbumped in this PR. An older node-agent ignores the variable, but it doesn't retry when the collector holds a request.Limit: an outage is absorbed while each container writes less than about one log file (10 MiB by default). Files rotated away in the meantime are compressed by the kubelet, and the node-agent doesn't read those.
The logs queue is in memory, so records waiting in it are lost if the collector itself restarts during a ClickHouse outage. A persistent queue is a follow-up.
Type of change
Chart version
versionincharts/nudgebee-agent/Chart.yaml(required for user-visible changes): 0.1.32Test plan
helm lint charts/nudgebee-agentpasses.ct lint --config .github/configs/ct.yaml: run by CI.helm templatereviewed. The default mode differs from main only in the collector config. The rendered config passesotelcol validateon collector-contrib 0.157.Related issues
Depends on nudgebee/node-agent#407 (and its nudgebee/logparser#36).