Repository navigation
Conversation
|
❌ Author of the following commits did not sign a Contributor Agreement: Please, read and sign the above mentioned agreement if you want to contribute to this project |
|
This pull request doesn't have a |
🤖 GitHub commentsJust comment with:
|
|
This pull request does not have a backport label.
To fixup this pull request, you need to add the backport labels for the needed
|
|
Tick the box to add this pull request to the merge queue (same as
|
leehinman
left a comment
There was a problem hiding this comment.
Nit on the changelog, otherwise everything looks good.
|
|
||
| component: libbeat | ||
|
|
||
| # issue: https://github.com/elastic/beats/issues/54639 |
There was a problem hiding this comment.
looks like the right issue, can you uncomment?
The disk queue treats max_size: 0 as unlimited: it reports MaxBytes(0) and never sets a maximum event count. updateFilledPct divided by the zero maximum anyway, so queue.filled.pct became +Inf while events were queued and NaN when the queue was empty. The non-finite value made the monitoring reporter fail with "json: unsupported value: +Inf" and broke the /stats endpoint. Only compute the percentage when a finite byte or event limit exists, and report 0 when the queue is unbounded, since it can never fill up. Assisted-By: Muse
17f125b to
4704000
Compare
Proposed commit message
The disk queue treats
max_size: 0as unlimited: it reportsMaxBytes(0)to the queue observer and never sets a maximum event count.queueObserver.updateFilledPct()inlibbeat/publisher/queue/monitoring.goguarded the byte division withmaxBytes > 0but then divided by the event maximum unconditionally, soqueue.filled.pctbecame +Inf while events were queued and NaN when the queue was empty. The non-finite value made the monitoring reporter fail with "json: unsupported value: +Inf" and broke the/statsendpoint, as reported in #54639.Fix: only compute the percentage when a finite byte or event limit exists. When the queue is unbounded, report 0. The
filled.pctgauge is initialized to 0, and an unbounded queue can never fill up. The finite-limit paths are unchanged.Tests:
libbeat/publisher/queue/monitoring_test.gois new (the package previously had no test files). Its two unlimited-queue cases fail on the old code with exactly +Inf and NaN, and pass with the fix. A third case pins the finite byte and event percentages (0.25 and 0.5) so the existing behavior cannot drift.go test ./libbeat/publisher/queue/...passes (queue, diskqueue, memqueue, slabqueue).A changelog fragment (
kind: bug-fix, componentlibbeat) is included in this PR.Checklist
I have made corresponding changes to the documentation(no documentation describes this metric's behavior for unlimited queues; the fix restores the documented/statsoutput)I have made corresponding change to the default configuration files(no configuration change;max_size: 0keeps its existing meaning of unlimited)stresstest.shscript to run them under stress conditions and race detector to verify their stability. (Unit tests only; stress testing is not relevant to this observer calculation.)./changelog/fragmentsusing the changelog tool.Disruptive User Impact
None. The only change is the value of
queue.filled.pctfor queues configured without a finite limit, where it previously held +Inf or NaN and broke monitoring output.How to test this PR locally
To reproduce the original failure, run the two unlimited-queue tests in
libbeat/publisher/queue/monitoring_test.goagainst the code without themonitoring.gochange: they fail with +Inf and NaN. End to end: run Filebeat with a disk queue configured withmax_size: 0, publish events, and request/stats; before the fix the monitoring reporter logs "json: unsupported value: +Inf", after the fixqueue.filled.pctreports 0.Related issues
Use cases
Users running Filebeat with an unlimited disk queue (
max_size: 0, a valid configuration) get a working/statsendpoint and monitoring output again;queue.filled.pctreports 0 instead of a non-finite value.Logs
New tests against the old code:
With the fix, all three tests pass and
go test ./libbeat/publisher/queue/...is green across queue, diskqueue, memqueue, and slabqueue.