collector: add nfqueue collector#3551
Conversation
aed9afd to
f846d6b
Compare
|
While I don't have an issue in general with vibe-coded contributions, it would be polite to make them as such and at least make sure the style (e.g tests using the fixtures instead) matched and its following naming best practices. @SuperQ We should probably figure out how to deal with that. Maybe if we hint AI agents the contributions would be even better at following our style and best practices than most human contributions 😬 |
|
@discordianfish I indeed used AI, but not blindly, I quickly hacked the solution myself, then asked AI to write the tests and brush up the code a little bit (to comply with the standards and fix a couple of issues it spot with the tests). I used AI to create the PR description - it's where I'm fully guilty :) P.S. And thanks for the review! |
852f8cb to
cc50a39
Compare
| } | ||
|
|
||
| func TestNFQueueStats(t *testing.T) { | ||
| testcase := `# HELP node_nfqueue_dropped_total Total number of packets dropped. |
There was a problem hiding this comment.
Is there a reason to not use the e2e fixtures instead of this test?
There was a problem hiding this comment.
Well, some other tests do that as well:
To me it looks like there is on the opposite no strong motivation to use e2e fixtures here. We would have to update end-to-end-test.sh then to enable this collector and then regenerate all fixtures. And given it's a niche one, I think it's cleaner to keep it here as a string instead.
WDYT?
cc50a39 to
349075f
Compare
349075f to
6b14744
Compare
Signed-off-by: Denis Voytyuk <5462781+denisvmedia@users.noreply.github.com>
6b14744 to
51cb233
Compare
Closes #3518
Summary
Add a new collector that exposes metrics from
/proc/net/netfilter/nfnetlink_queue, enabling monitoring of NFQUEUE userspace packet processing queues.The collector is disabled by default and can be enabled with
--collector.nfqueue. It can be excluded at build time with thenonfqueuebuild tag.Motivation
NFQUEUE is used by many common network security tools — fail2ban, Suricata (IPS mode), Snort, and custom libnetfilter_queue applications. When a queue fills up, packets are silently dropped by the kernel, which is notoriously hard to diagnose without direct access to the host. This collector makes that state observable.
Metrics
node_nfqueue_queue_totalnode_nfqueue_dropped_totalreasonlabel:queue_full(queue was full) oruser(failed to send to userspace)node_nfqueue_infopeer_portid,copy_mode,copy_rangeAll metrics carry a
queuelabel with the queue ID. Thecopy_modelabel innode_nfqueue_infois a human-readable string:none,meta, orpacket.Example output for a live system with one active queue:
Implementation notes
procfs.NFNetLinkQueue()fromgithub.com/prometheus/procfs— already present in the dependency tree at v0.19.2 (added in procfs#677). No dependency changes required.ErrNoDataif/proc/net/netfilter/nfnetlink_queuedoes not exist, so the collector does not produce errors on systems where NFQUEUE is not in use.Testing
Unit tests added in
collector/nfqueue_linux_test.gousingtestutil.GatherAndCompareagainst a fixture file with three synthetic queue entries (collector/fixtures/proc/net/netfilter/nfnetlink_queue). Tests pass on Linux (verified via Docker).The collector was also validated against a live Linux host where an active NFQUEUE queue was present, confirming correct metric emission with real kernel data.