in_podman_metrics: add exclude_name_regex option#11968
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (3)
📝 WalkthroughWalkthroughThe podman_metrics input plugin gains an ChangesContainer Name Exclusion via Regex
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Companion documentation PR: fluent/fluent-bit-docs#2604 Testing evidenceBuilt via Yocto (Fluent Bit 5.0.2 base) and run on an aarch64 Linux device pipeline:
inputs:
- name: podman_metrics
scrape_interval: 60
scrape_on_start: true
exclude_name_regex: '-(infra|service)$'With 9 containers running (3 application + 6 pod No I can add Valgrind output from a dedicated local build if that is required for |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@plugins/in_podman_metrics/podman_metrics.c`:
- Around line 451-460: The ctx->exclude_name_regex is allocated on line 453 but
not freed when subsequent initialization failures occur at later return paths.
To fix this, add a call to flb_regex_destroy on ctx->exclude_name_regex before
any flb_free(ctx) and return statement that comes after the regex compilation,
particularly at the error paths around line 467 and line 499 where init can
fail. Ensure that all error return paths after ctx->exclude_name_regex is
created properly clean up the compiled regex object to prevent memory leaks on
failed plugin initialization.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 897e2997-f1c6-4a11-8388-98625cba7b5e
📒 Files selected for processing (3)
plugins/in_podman_metrics/podman_metrics.cplugins/in_podman_metrics/podman_metrics.hplugins/in_podman_metrics/podman_metrics_config.h
3cff87a to
e7ae0d1
Compare
Document the new exclude_name_regex configuration option for the in_podman_metrics input plugin, added in fluent/fluent-bit#11968. The option skips containers whose name matches a user-supplied regular expression before their metrics are collected (for example pod infra and service containers). Signed-off-by: Stefano Tondo <stondo@gmail.com>
Add an optional 'exclude_name_regex' configuration option to skip containers whose name matches a user-supplied regular expression before their metrics are collected and emitted. This mirrors the regex filtering model already used by the node exporter (netdev.ignore_device_regex) and the diskstats/filesystem collectors. A typical use is dropping Podman pod infrastructure containers, e.g. exclude_name_regex '-(infra|service)$' to skip pause and catatonit containers that carry no useful application metrics. The option defaults to unset, so existing behaviour (collect every container) is unchanged. Signed-off-by: Stefano Tondo <stondo@gmail.com>
e7ae0d1 to
3a93258
Compare
Summary
Add an optional
exclude_name_regexconfiguration option toin_podman_metricsthat skips containers whose name matches a user-supplied regular expression,
before their metrics are collected and emitted.
This mirrors the regex-filtering model already used elsewhere in Fluent Bit,
e.g.
netdev.ignore_device_regexinin_node_exporter_metrics. A typical useis dropping Podman pod infrastructure containers, for example
exclude_name_regex '-(infra|service)$'to skip the pause and catatonitcontainers that carry no useful application metrics.
The option defaults to unset, so existing behaviour (collect every container)
is unchanged and the feature is fully opt-in.
Example configuration
Implementation
FLB_CONFIG_MAP_STRoptionexclude_name_regex(defaultNULL).in_metrics_initviaflb_regex_create.(
flb_free(ctx); return -1) beforeflb_input_set_contextandflb_input_set_collector_time, so no collector is ever armed against anuninitialised context.
collect_container_data, a container is skipped when its name matchesthe compiled regex; otherwise it is added and counted as before.
in_metrics_exit.Testing
exclude_name_regex '-(infra|service)$': only application containersemit metrics; pod
-infra/-service(pause/catatonit) containers areexcluded at the source. Verified via the prometheus exporter output.
container emitted).
could not compile exclude_name_regex '<value>',no crash and no armed collector.
Documentation
fluent-bit-docsdocuments the newexclude_name_regexoption.Signed-off-by: Stefano Tondo stondo@gmail.com
Summary by CodeRabbit
Release Notes
New Features
exclude_name_regex).Bug Fixes
"unknown"instead of leaving it unset.