# eBPF for Developers: Zero-Instrumentation Observability and Security in 2026

> eBPF for developers: how it works, zero-code tracing and metrics, bpftrace one-liners, Cilium and Tetragon, and where it falls short.

Source: https://www.derar.dev/blog/ebpf-observability-for-developers-2026 · Published 2026-11-11 · Updated 2026-11-14 · By Derar Sattouf

Traditional observability asks you to change your code: add a tracing SDK, wrap every HTTP client, ship a log line for each interesting event. That works, but it leaves gaps: services you can't modify, third-party binaries, legacy systems, and the entire layer beneath your application (kernel, network, disk). **eBPF** closes those gaps by letting you run small, verified programs inside the Linux kernel, observing what the system does without touching the applications above it.

By 2026, eBPF underpins the networking layer of many Kubernetes clusters (Cilium), runtime security tools (Tetragon, Falco's modern driver), and a growing family of zero-code observability products.

You attach sandboxed programs to kernel events (syscalls, network packets, function entry and exit, tracepoints) and collect data with low overhead, with no application changes or restarts. A verifier checks every program before it loads, making sure it terminates and can't crash the kernel or read arbitrary memory. The practical wins are latency and error metrics for any service, network flow maps, continuous CPU profiling, runtime security detection, and debugging production issues on live processes.

You'll rarely write eBPF directly. Use bpftrace for ad hoc investigation and ready-made tools (Cilium, Tetragon, Pixie, Grafana Beyla, Parca, Pyroscope) for continuous use. The limits are real: it's Linux only, it needs a reasonably modern kernel and privileged access, encrypted payloads stay opaque unless you hook the TLS library, and it complements application-level tracing rather than replacing it.

## How eBPF works

```text
 user space                          kernel space
┌──────────────┐  load program  ┌────────────────────────────┐
│ bpftrace /   │───────────────>│ Verifier (safety checks)   │
│ agent / CLI  │                │   -> JIT compile           │
└──────┬───────┘                │   -> attach to hook        │
       │ read results           └──────────────┬─────────────┘
       │                                       │ runs on event
       │        ┌─────────────┐                ▼
       └────────│ BPF maps /  │<──── kprobe / uprobe / tracepoint /
                │ ring buffer │      XDP / TC / LSM / perf event
                └─────────────┘
```

The pieces:

1. **Hooks**: where your program runs. Common types include **kprobes** (kernel function entry/exit), **uprobes** (user-space function entry/exit in any binary), **tracepoints** (stable kernel instrumentation points), **perf events** (sampling for profiling), **XDP/TC** (network packet processing), and **LSM** hooks (security decisions).
2. **The verifier**: static analysis that rejects programs with unbounded loops, invalid memory access, or unsafe helper use. This is why eBPF is considered safe to run in production compared to loadable kernel modules.
3. **Maps**: shared key-value structures (hash maps, arrays, histograms, ring buffers) through which kernel programs and user space exchange data.
4. **CO-RE (Compile Once, Run Everywhere)** with BTF type information lets one compiled program adapt to different kernel versions, which is what made production tooling practical.

Typical overhead is small (often low single-digit percent CPU for well-designed tools), because filtering and aggregation happen in the kernel and only summaries cross into user space.

## Your first investigations with bpftrace

`bpftrace` is a high-level tracing language for eBPF, great for one-off questions on a live box. Run these as root on a Linux host (kernel 5.x or later recommended; check your distribution's package).

### Which processes are opening which files?

```bash
sudo bpftrace -e 'tracepoint:syscalls:sys_enter_openat { printf("%s -> %s\n", comm, str(args->filename)); }'
```

### Syscall counts by process (what is this noisy service doing?)

```bash
sudo bpftrace -e 'tracepoint:raw_syscalls:sys_enter { @[comm] = count(); } interval:s:5 { exit(); }'
```

### Disk I/O latency histogram

```bash
sudo bpftrace -e '
tracepoint:block:block_rq_issue { @start[args->dev, args->sector] = nsecs; }
tracepoint:block:block_rq_complete /@start[args->dev, args->sector]/ {
  @usecs = hist((nsecs - @start[args->dev, args->sector]) / 1000);
  delete(@start[args->dev, args->sector]);
}'
```

This uses stable block-layer tracepoints. Older tutorials attach kprobes to internal functions such as `blk_account_io_start`, which are renamed or inlined across kernel versions and then fail to attach; prefer tracepoints when one exists. The output is a power-of-two histogram that immediately shows bimodal latency (cache hits versus real disk reads), a classic mystery solved in seconds.

### Who is making outbound TCP connections?

```bash
sudo bpftrace -e 'kprobe:tcp_connect { printf("%s (pid %d) connecting\n", comm, pid); }'
```

### Trace a function inside a running binary (uprobe)

Measure how long a Go or C function takes in a live process, without restarting it:

```bash
sudo bpftrace -e '
uprobe:/usr/local/bin/myserver:main.handleRequest { @start[tid] = nsecs; }
uretprobe:/usr/local/bin/myserver:main.handleRequest /@start[tid]/ {
  @latency_us = hist((nsecs - @start[tid]) / 1000);
  delete(@start[tid]);
}'
```

Notes: Go function return probes are tricky because of how the Go runtime moves goroutine stacks, so tools targeting Go often hook function *entry* and use other strategies for exits. Symbols require a non-stripped binary. Test carefully on a staging system first.

## Zero-code application observability

Several projects use eBPF to produce RED metrics (rate, errors, duration) and distributed trace spans for HTTP, gRPC, and database traffic, automatically, for any language.

| Tool | What it gives you |
| --- | --- |
| **Grafana Beyla** | Auto-instrumented HTTP/gRPC metrics and traces exported as OpenTelemetry, no code changes |
| **Pixie** | Kubernetes-native: request traces, service maps, and profiling via scripts, with data stored in-cluster |
| **OpenTelemetry eBPF Instrumentation (OBI)** | Grafana donated Beyla's technology to the OpenTelemetry project, where it continues as a vendor-neutral eBPF auto-instrumentation component; check the project's docs for current naming and status |
| **Odigos** | Auto-instrumentation across languages (eBPF and SDK-based) feeding OTel pipelines |
| **Coroot, Groundcover, others** | Full observability products built around eBPF collection |

Typical deployment is one DaemonSet per node:

```yaml
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: beyla
  namespace: observability
spec:
  selector:
    matchLabels: { app: beyla }
  template:
    metadata:
      labels: { app: beyla }
    spec:
      hostPID: true                       # required to see processes on the node
      serviceAccountName: beyla
      containers:
        - name: beyla
          image: grafana/beyla:latest     # pin a real version in production
          securityContext:
            privileged: false
            capabilities:
              add: ["BPF", "PERFMON", "NET_RAW", "DAC_READ_SEARCH", "SYS_PTRACE"]
          env:
            - name: BEYLA_OPEN_PORT
              value: "8080,3000"          # which service ports to instrument
            - name: OTEL_EXPORTER_OTLP_ENDPOINT
              value: "http://otel-collector.observability:4318"
```

(The exact capability set and configuration differ per tool and version; follow its documentation.) Note that these agents need powerful privileges, so treat them as part of your trusted computing base and restrict who can deploy them.

### What you get, and what you don't

You get: request rates, error rates, latency distributions, endpoint (route) breakdown, upstream/downstream service relationships, and database or Redis call timings, all without a code change or restart, including for third-party and legacy services.

You don't automatically get business context (user ID, order ID, feature flag), custom span attributes, or deep in-process timing between functions. For those you still want OpenTelemetry SDK instrumentation. The best setup is layered: eBPF for baseline coverage everywhere, SDKs where richer context pays off.

### The TLS problem

Because eBPF in the kernel sees encrypted bytes on the wire, tools capture HTTPS payloads by attaching uprobes to TLS library functions (OpenSSL `SSL_read`/`SSL_write`, Go's `crypto/tls`, BoringSSL, and so on) before encryption or after decryption. This works for common libraries but can break with statically linked or unusual TLS stacks. If you need strict data minimization, configure the tools to capture only metadata (method, route, status, duration) rather than bodies.

### eBPF versus SDK versus sidecar: choosing

| Concern | eBPF agent | OpenTelemetry SDK in code | Service-mesh sidecar |
| --- | --- | --- | --- |
| Needs code change or restart | No | Yes | No (but pod restart to inject) |
| Language coverage | Broad for supported protocols | Per-language SDKs | Language-neutral, network level |
| Business attributes and custom spans | Limited | Full | None |
| Visibility into in-process function timing | Only with uprobes | Yes | No |
| Works on managed or serverless | Often restricted | Yes | Depends |
| Privilege requirements | High (node level) | None | Moderate |
| Typical use | Baseline coverage and legacy services | Rich application telemetry | mTLS and traffic policy |

Pair this with the application-level approach in [OpenTelemetry for LLM apps](https://www.derar.dev/blog/opentelemetry-for-llm-apps-2026) and with [SLOs and error budgets](https://www.derar.dev/blog/slos-error-budgets-incident-response-2026): eBPF metrics are an excellent source for SLIs on services you did not instrument.

## Continuous profiling

Sampling profilers built on eBPF (Parca, Grafana Pyroscope's eBPF mode, Polar Signals, and others) periodically capture stack traces of every process on the host with very low overhead (often under 1-2 percent), and aggregate them into flame graphs over time.

Why it matters:

- You can answer "what was consuming CPU at 3 a.m. last Tuesday?" after the fact.
- You can compare flame graphs before and after a deploy to catch regressions.
- It works without per-language profiler setup, though symbolization quality varies: native languages with frame pointers or debug info work best, while JIT languages (Java, Node, Python) need extra support such as perf maps or language-specific agents.

Build your binaries with frame pointers (modern Go does by default; for Rust set `RUSTFLAGS="-C force-frame-pointers=yes"`; for C/C++ use `-fno-omit-frame-pointer`) to get accurate stacks.

```bash
# One-off CPU profile of everything on the host for 30s, using perf as a baseline
sudo perf record -F 99 -a -g -- sleep 30
sudo perf script | stackcollapse-perf.pl | flamegraph.pl > cpu.svg
```

## Networking: Cilium and Hubble

Cilium uses eBPF as a Kubernetes CNI, replacing iptables-based packet processing with in-kernel programs. Benefits include higher performance at scale, identity-based network policy, optional kube-proxy replacement, and transparent encryption options. Hubble, its observability layer, shows real-time flows between pods with allow/deny verdicts.

```bash
# See which flows are being dropped in a namespace
hubble observe --namespace production --verdict DROPPED --follow

# Who talks to the database?
hubble observe --to-label app=postgres --namespace production
```

A Cilium network policy can express rules at layer 7:

```yaml
apiVersion: cilium.io/v2
kind: CiliumNetworkPolicy
metadata:
  name: api-to-payments
  namespace: production
spec:
  endpointSelector:
    matchLabels: { app: api }
  egress:
    - toEndpoints:
        - matchLabels: { app: payments }
      toPorts:
        - ports: [{ port: "8080", protocol: TCP }]
          rules:
            http:
              - method: "POST"
                path: "/v1/charges"
```

For debugging, the flow map answers "what is this service actually talking to?" faster than any architecture diagram.

## Runtime security with Tetragon (and similar)

eBPF can enforce and detect at the point where behavior actually happens: process execution, file access, network connections, and privilege changes. Tetragon (from the Cilium project) and Falco use eBPF to watch for suspicious activity with low overhead, and Tetragon can even block actions in-kernel.

```yaml
apiVersion: cilium.io/v1alpha1
kind: TracingPolicy
metadata:
  name: block-shadow-read
spec:
  kprobes:
    - call: "security_file_open"
      syscall: false
      args:
        - index: 0
          type: "file"
      selectors:
        - matchArgs:
            - index: 0
              operator: "Equal"
              values: ["/etc/shadow"]
          matchBinaries:
            - operator: "NotIn"
              values: ["/usr/sbin/sshd", "/usr/bin/login"]
          matchActions:
            - action: Sigkill
```

Detection examples: a shell spawned in a web-server container, a process reading service account tokens, outbound connections to unexpected IPs, writes to `/etc` or binary directories, loading kernel modules. Start in audit or alert mode, tune out false positives from legitimate behavior, and only then enable blocking actions.

## Writing your own eBPF programs

Most developers won't need to, but it helps to see what it involves. A minimal program using libbpf-style C with CO-RE:

```c
// execsnoop.bpf.c : log every execve with the process name
#include "vmlinux.h"
#include <bpf/bpf_helpers.h>

struct event { __u32 pid; char comm[16]; };

struct {
    __uint(type, BPF_MAP_TYPE_RINGBUF);
    __uint(max_entries, 1 << 24);
} events SEC(".maps");

SEC("tracepoint/syscalls/sys_enter_execve")
int handle_exec(struct trace_event_raw_sys_enter *ctx) {
    struct event *e = bpf_ringbuf_reserve(&events, sizeof(*e), 0);
    if (!e) return 0;
    e->pid = bpf_get_current_pid_tgid() >> 32;
    bpf_get_current_comm(&e->comm, sizeof(e->comm));
    bpf_ringbuf_submit(e, 0);
    return 0;
}

char LICENSE[] SEC("license") = "GPL";
```

Production-grade programs are usually written in C with `libbpf`, in Rust with Aya, or in Go with `cilium/ebpf`, with a user-space loader that reads the ring buffer. Rust and Go loaders are attractive because the user-space half is ordinary application code. Expect a learning curve around the verifier's constraints (bounded loops, strict pointer tracking, stack limit of 512 bytes).

## Limits, risks, and operational advice

- **Linux only.** Windows has an eBPF implementation with narrower scope; macOS has no equivalent, so local developer machines (and many managed or serverless runtimes) can't run these tools. Docker Desktop and Colima run a Linux VM where you can.
- **Kernel version matters.** Features arrive over kernel releases; enterprise distributions backport selectively. Check support for the program types and BTF your tools require.
- **Privileges**: loading programs needs `CAP_BPF` and related capabilities (or root). An eBPF agent with broad capabilities is a high-value target. Limit access, pin versions, verify image provenance, and monitor the agents themselves.
- **Managed Kubernetes and serverless**: some providers restrict privileged DaemonSets or host PID access (Fargate-style environments generally can't run node agents). Confirm before designing around eBPF.
- **Data sensitivity**: capturing payloads can expose secrets and personal data. Prefer metadata-only collection and apply redaction.
- **Overhead is low, not zero.** High-frequency probes (every packet, every syscall) on busy hosts can add measurable cost. Aggregate in-kernel, filter early, and benchmark under production load.
- **Coverage gaps**: unusual protocols, statically linked TLS, and heavily stripped binaries reduce fidelity.

### Check what your kernel supports

```bash
uname -r                                   # kernel version
ls /sys/kernel/btf/vmlinux                 # BTF available? (needed for CO-RE tools)
sudo bpftool feature probe | head -40      # supported program and map types
sudo bpftool prog list                     # eBPF programs currently loaded (audit your agents)
sudo bpftrace -l 'tracepoint:syscalls:*' | head
```

Run `bpftool prog list` and `bpftool map list` on your nodes occasionally: it is the quickest way to see what is actually loaded and by whom.

### Lab: find a slow, chatty process on a Linux VM

You can do this on any Linux VM, including Multipass, Lima, or a cloud instance.

```bash
# 1. Install tools (Debian or Ubuntu names; verify on your distro)
sudo apt-get install -y bpftrace bpfcc-tools linux-tools-generic

# 2. Create some noise
(while true; do curl -s https://example.com >/dev/null; sleep 0.2; done) &

# 3. Who is connecting out? (bcc tool; may be named tcpconnect-bpfcc)
sudo tcpconnect-bpfcc

# 4. Which files does it touch?
sudo opensnoop-bpfcc -p $(pgrep -n curl)

# 5. Syscall summary for 5 seconds
sudo bpftrace -e 'tracepoint:raw_syscalls:sys_enter { @[comm] = count(); } interval:s:5 { exit(); }'

# 6. Stop the background loop
kill %1
```

On macOS, run these inside a Linux VM, since the host kernel has no eBPF. The `libbpf-tools` and `bcc-tools` packages include many ready-made tools (`execsnoop`, `biolatency`, `tcpretrans`, `runqlat`) that are good first tools to learn before writing programs.

### Debugging recipes

| Question | Approach |
| --- | --- |
| Why is the host slow right now? | `runqlat` (CPU scheduling delay), `biolatency` (disk), `tcpretrans` (network retransmits) |
| What is spawning short-lived processes? | `execsnoop` |
| Which service is making unexpected outbound calls? | `tcpconnect` or Hubble flows |
| Is DNS the problem? | Trace DNS lookups with `gethostlatency` or Hubble DNS visibility |
| Who is reading this file? | `opensnoop` with a filename filter, or a Tetragon policy in audit mode |
| Which function burns CPU in production? | Continuous profiler flame graph; compare before and after the deploy |

## A sensible adoption order

Start with bpftrace on a staging host and answer three real questions about your own system: is a disk slow, is a service chatty, is something making an unexpected outbound connection? If you run Cilium, add Hubble or flow visibility. Otherwise consider a service map from an eBPF observability tool to discover real dependencies.

Next, deploy zero-code RED metrics (Beyla or similar) to services that have no instrumentation, exporting through OpenTelemetry to the backend you already use. Enable continuous profiling across the fleet and make flame graph comparison part of your post-deploy checks.

Introduce runtime security (Tetragon or Falco) in alert-only mode, and promote high-confidence rules to enforcement gradually. Keep SDK instrumentation for business-level attributes, and use trace context propagation to connect both layers.

## Where this usually goes wrong

- Treating eBPF agents as harmless: they run with node-level privileges.
- Attaching kprobes to internal kernel functions that disappear in the next kernel; prefer tracepoints.
- Forgetting frame pointers and symbols, then getting useless flame graphs.
- Collecting request bodies via TLS uprobes without a data-protection review.
- Turning on blocking security policies without an audit period.
- Deploying one agent per feature (metrics, profiling, security, networking) without measuring their combined overhead.
- Assuming eBPF replaces application tracing; it does not know your business context.

## Questions that come up

**Is eBPF safe in production?** The verifier prevents programs from crashing the kernel, and mature tools are widely deployed. Bugs and misconfigurations still happen, so test, pin versions, and monitor overhead.

**Does eBPF work in containers and Kubernetes?** Yes, since containers share the host kernel; agents run per node and need privileged access to the host. Some managed or serverless platforms disallow this.

**Which kernel version do I need?** Many features work from kernel 4.x, but modern CO-RE tools generally want 5.x or later with BTF. Check each tool's requirements.

**What about Windows or macOS?** Windows has a separate eBPF project with limited scope; macOS has none. Use a Linux VM.

**Can I write eBPF in Rust or Go?** Yes: Aya (Rust) and cilium/ebpf (Go) are common, with user-space code in the same language. See [Rust, Axum and Tokio production services](https://www.derar.dev/blog/rust-axum-tokio-production-services-2026) for the Rust ecosystem and [Go 1.26 for backend engineers](https://www.derar.dev/blog/go-1-26-backend-engineers-guide-2026).

**How does it relate to security hardening?** Runtime detection complements image scanning and policy; see [container security hardening for Docker and Kubernetes](https://www.derar.dev/blog/container-security-hardening-docker-kubernetes-2026) and [software supply chain: SLSA, Sigstore and SBOMs](https://www.derar.dev/blog/software-supply-chain-slsa-sigstore-sbom-2026).

## Sources and docs

- [ebpf.io: what is eBPF](https://ebpf.io/what-is-ebpf/)
- [bpftrace reference guide](https://github.com/bpftrace/bpftrace/blob/master/docs/reference_guide.md)
- [Brendan Gregg's eBPF resources](https://www.brendangregg.com/ebpf.html)
- [Cilium documentation](https://docs.cilium.io)
- [Tetragon documentation](https://tetragon.io/docs/)
- [Grafana Beyla documentation](https://grafana.com/docs/beyla/latest/)
- [Parca](https://www.parca.dev) and [Grafana Pyroscope](https://grafana.com/oss/pyroscope/)
- [Aya (Rust eBPF)](https://aya-rs.dev)
- [cilium/ebpf (Go)](https://github.com/cilium/ebpf)
- Related on this site: [platform engineering for small teams](https://www.derar.dev/blog/platform-engineering-small-teams-2026), [Docker complete course](https://www.derar.dev/blog/docker-complete-course-2026)
