eBPF Filedescriptor
Plugin: ebpf-go.plugin Module: fd
Overview
Monitor calls for functions responsible to open or close a file. Setting fd = yes enables collection and the host-wide charts only; the per-application and per-cgroup charts additionally require apps = yes and/or cgroups = yes in the [global] section. The error charts require ebpf load mode = return; the counters behind them are always collected, but they are only charted in that mode, as in the C implementation of this collector.
Attach a return probe to the kernel's open and close entry points, using the object flavor selected for the running kernel.
This collector is only supported on the following platforms:
- Linux
This collector supports collecting metrics from multiple instances of this integration, including remote instances.
The plugin needs setuid because it loads data inside kernel. Netdata sets necessary permission during installation time.
eBPF Filedescriptor can be monitored further using the following other integrations:
Default Behavior
Auto-Detection
The plugin checks kernel compilation flags (CONFIG_KPROBES, CONFIG_BPF, CONFIG_BPF_SYSCALL, CONFIG_BPF_JIT), presence of BTF files, and the configured object flavor to decide which eBPF program will be attached. The attach symbols differ by kernel version and architecture, so the collector resolves them from /proc/kallsyms before attaching. Open uses do_sys_openat2, then do_sys_open: both are inner functions that open, openat and openat2 all funnel through. Close uses the architecture's close(2) syscall symbol (__x64_sys_close, __arm64_sys_close, ..., or the unprefixed sys_close on architectures without syscall wrappers), falling back to the inner helpers close_fd and __close_fd on kernels that predate the wrappers. The inner helper is not used on newer kernels because the close(2) syscall no longer calls it, which made the close counters read zero.
Limits
The default configuration for this integration does not impose any limits on data collection.
Performance Impact
This thread will add overhead every time that an internal kernel function monitored by this thread is called.
Setup
Prerequisites
Compile kernel
Check if your kernel was compiled with necessary options (CONFIG_KPROBES, CONFIG_BPF, CONFIG_BPF_SYSCALL, CONFIG_BPF_JIT) in /proc/config.gz or inside /boot/config file. Some cited names can be different according to the preferences of Linux distributions.
When you do not have options set, it is necessary to get the kernel source code from https://kernel.org or a kernel package from your distribution, this last is preferred. The kernel compilation has a well defined pattern, but distributions can deliver their configuration files
with different names.
Now follow steps:
- Copy the configuration file to /usr/src/linux/.config.
- Select the necessary options: make oldconfig
- Compile your kernel image: make bzImage
- Compile your modules: make modules
- Copy your new kernel image for boot loader directory
- Install the new modules: make modules_install
- Generate an initial ramdisk image (
initrd) if it is necessary. - Update your boot loader
Configuration
Options
The fd option in section [ebpf programs] controls whether the module is loaded.
The options listed below are [global] overrides.
Config options
| Option | Description | Default | Required |
|---|---|---|---|
| update every | Data collection frequency. This configuration value takes precedence over the runtime interval passed by pluginsd. | 10 | no |
| ebpf load mode | Selects whether the error charts are published. entry collects and charts only the call counts; return and its legacy alias dev additionally publish filesystem.file_error and the per-application and per-cgroup error charts. Attachment is unaffected: the probes always read the syscall return value, so switching modes costs nothing at collection time. | entry | no |
| apps | Enable or disable integration with apps.plugin | no | no |
| cgroups | Enable or disable integration with cgroup.plugin | no | no |
| pid table size | Number of elements stored inside hash tables used to monitor calls per PID. | 32768 | no |
| ebpf object flavor | Select the fd object flavor to load. Available values are arena, buffer ring (also accepted as buffer), and legacy (also accepted as tracing). The default is buffer, and the collector falls back when the requested flavor is not available on the system. | buffer | no |
| ebpf type format | Legacy key from the C ebpf.plugin, kept so migrated configurations still parse. It maps onto ebpf object flavor: legacy forces the kprobe-based tracing objects, while co-re and auto are accepted no-ops that leave the flavor to auto-detection. Prefer ebpf object flavor in new configurations. | auto | no |
| ebpf co-re tracing | Select the attach method used by plugin when co-re is defined in previous option. Two options are available: trampoline (Option with lowest overhead), and probe (the same of legacy code). | trampoline | no |
| maps per core | Define how plugin will load their hash maps. When enabled (yes) plugin will load one hash table per core, instead to have centralized information. | yes | no |
| btf path | Override the default BTF source directory. The collector checks this path for a vmlinux BTF file used by CO-RE loading. | /sys/kernel/btf | no |
| collect pid | Controls which PIDs are stored in the BPF hash tables. real parent stores only the real parent PID (lowest overhead); parent stores the immediate parent PID; all stores every PID used by the process (highest overhead). | real parent | no |
| lifetime | Set default lifetime for thread when enabled by cloud. | 300 | no |
via File
The configuration file name for this integration is ebpf.d.conf.
You can edit the configuration file using the edit-config script from the
Netdata config directory.
cd /etc/netdata 2>/dev/null || cd /opt/netdata/etc/netdata
sudo ./edit-config ebpf.d.conf
Examples
There are no configuration examples.
Alerts
There are no alerts configured by default for this integration.
Metrics
Metrics grouped by scope.
The scope defines the instance that the metric belongs to. An instance is uniquely identified by a set of labels.
Per eBPF Filedescriptor instance
These metrics show the host-wide rate of file open and close calls, and of the ones that failed.
This scope has no labels.
Metrics:
| Metric | Description | Dimensions | Unit |
|---|---|---|---|
| filesystem.file_descriptor | Open and close calls. Published as cumulative kernel counters with the incremental algorithm, preserving the legacy filedescriptor metric contract. | open, close | calls/s |
| filesystem.file_error | Open and close calls that returned an error. Published only in the non-entry load modes, ebpf load mode = return and its legacy alias dev. | open, close | calls/s |
Do you have any feedback for this page? If so, you can open a new issue on our netdata/learn repository.