Bedrock is an eBPF-based tracing tool for monitoring file access through:
- VFS operations
- regular I/O operations
- memory map operations
It can trace workloads running directly on the host or inside containers.
Bedrock supports tracing by:
- a running PID (
--pid) - a process name (
--procname) - executing and tracing a command (
--execute) - a cgroup id (
--cgroup) - a container id/name (
--container) - a Kubernetes pod (
--kubernetes__pod)
After cloning this repository:
make
source .venv/bin/activateVerify installation:
bdtrace --helpNOTE: bdtrace needs privileged access for tracing.
Trace a command:
sudo $(which bdtrace) --execute lsTrace a running process:
sudo $(which bdtrace) --pid <PID>Trace by process name:
sudo $(which bdtrace) --procname <PROCESS_NAME>Print full CLI help:
bdtrace --helpMain options:
-o, --out: output directory (default:./logs)-r, --rotate: enable log rotation--rotate_size: log rotation size (default:100MB)--version: bpftrace scripts version (default:v1)--headless: disable metadata capture--disable_vfs: disable VFS tracer--disable_io: disable I/O tracer--disable_memory_map: disable mmap tracer-d, --debug: enable debug logs
Trace target selectors (choose one):
--execute <COMMAND>--pid <PID>--cgroup <CGROUP_ID>--procname <NAME>--container <CONTAINER>--kubernetes__pod <POD>(optional:--kubernetes__namespace,--kubernetes__container)
Bedrock can run fully inside a Docker container. Because tracing depends on kernel interfaces, run the container with elevated privileges and host mounts.
Build the image:
docker build -f build/Dockerfile -t bedrock-tracer .Run a trace command and write logs to a host directory:
mkdir -p logs
docker run --rm \
--privileged \
--pid=host \
-v /sys:/sys:rw \
-v /lib/modules:/lib/modules:ro \
-v "$(pwd)/logs:/logs" \
bedrock-tracer \
bdtrace --execute ls -o /logs/trace_lsRun help inside the image:
docker run --rm bedrock-tracer bdtrace --helpFor additional containerized examples (including end-to-end and Kubernetes-oriented runs), see docker-compose.yaml.
Cause: container is missing required privileges for eBPF tracing.
Fix: run with both --privileged and --pid=host.
Cause: required host kernel paths are not mounted.
Fix: mount these paths into the container:
-v /sys:/sys:rw -v /lib/modules:/lib/modules:roCause: target process ended quickly, or filters do not match the real workload.
Fix:
- start with
--execute <command>to validate baseline tracing - verify PID/process/container values are correct
- run with
-dto enable debug logs
Cause: host kernel and available tracepoints/kprobes may not support the selected script version.
Fix:
- try
--version v0or--version v1 - run a minimal command first:
bdtrace --execute ls - verify host compatibility using scripts in
bpftrace/kernel_support.sh
Cause: output path is not writable from inside the container.
Fix:
- bind mount a writable host directory (for example
$(pwd)/logs:/logs) - pass
-o /logs/<trace_name>inbdtrace
Cause: tracer process can't access the host's docker container socket.
Fix:
- try
-v /var/run/docker.sock:/var/run/docker.sockis you want to trace a container when running bedrock inside a container
All tracing modes require root privileges.
If bdtrace is installed in a virtual environment, use:
sudo $(which bdtrace) --execute lsThe cli program is a process coordinator. It launches multiple bpftrace commands as child processes, grouped by tracer type:
- VFS tracer
- I/O tracer
- mmap tracer
Each tracer runs in its own thread so the coordinator remains non-blocking. Each thread pipes child stdout and stderr either to files or to the coordinator's stdout.
The main process periodically monitors child state:
- A tracer fails: the thread raises a failure event, and the main process stops all remaining tracers before cleanup.
- A tracer exits normally: the thread raises a stop event; once all tracers have stopped, cleanup starts.
- A
SIGTERMis received: the main process signals all tracer threads to stop, then proceeds to cleanup.
During cleanup, all bpftrace child processes are terminated to avoid leaving stale tracing processes attached to the kernel.