Back to Articles

Sysdig: The Universal System Call Translator That Turns Your Linux Kernel Into a Time Machine

[ View on GitHub ]

Sysdig: The Universal System Call Translator That Turns Your Linux Kernel Into a Time Machine

Hook

A single sysdig command can capture every system call, file operation, network packet, and container event on your Linux machine—then let you rewind and replay them days later as if you were watching it live.

Context

Linux system troubleshooting has historically been a Frankenstein's monster of specialized tools. Want to trace system calls? Use strace. Network traffic? Fire up tcpdump. File operations? Try lsof. Process activity? htop or top. Container internals? Good luck correlating docker stats with what's actually happening at the kernel level. Each tool speaks its own language, captures data in its own format, and requires you to know exactly what you're looking for before you start.

This fragmentation becomes painful during production incidents. You suspect a performance issue involves both network I/O and file system operations, but strace shows you syscalls without network context, and tcpdump shows packets without understanding which container or process generated them. By the time you've assembled the full picture from multiple tools, the transient issue has disappeared. Sysdig emerged from this frustration in 2013, built by Loris Degioanni (co-creator of Wireshark) with a radical premise: what if one tool could capture everything at the kernel level, understand container boundaries, and let you filter the firehose of data with a consistent query language?

Technical Insight

Userspace

Kernel Space

Raw syscall events

Event stream

Decoded events

Enriched with context

process/container/FD state

Filters & Chisels

Kernel Driver

Module or eBPF

Ring Buffer

libscap

System Capture

libsinsp

Event Processing

CLI Tools

sysdig/csysdig

System architecture — auto-generated

Sysdig's architecture revolves around a kernel-level interception layer that captures all system calls and OS events before they're processed. You have two options: a kernel module that hooks directly into the syscall table, or an eBPF probe that uses modern Berkeley Packet Filter technology for safer, more portable instrumentation. Both approaches funnel raw event data through a ring buffer into userspace where libscap (system capture library) and libsinsp (system inspection library) decode and enrich the events with context—process trees, container metadata, file descriptor tables, and network connections.

The magic happens in how Sysdig reconstructs high-level application behavior from low-level syscalls. When your application opens a file, Sysdig doesn't just see an open() call with a file descriptor number—it tracks that descriptor through subsequent read(), write(), and close() operations, maintaining complete state. Here's a practical example of filtering for all MySQL queries that took longer than 1 second:

# Capture all events to a file for later analysis
sudo sysdig -w capture.scap

# Later, filter the capture for slow MySQL queries
sysdig -r capture.scap -c spy_users "evt.type=write and fd.name contains /mysql/ and evt.latency > 1000000000"

# Or watch live with container context
sudo sysdig -pc -c topprocs_cpu container.name=mysql-prod

The -c flag invokes "chisels"—Lua scripts that implement common analysis patterns. But the real power is the filtering language. Unlike grep-based approaches, Sysdig filters operate on structured event fields. You can write proc.name=nginx and evt.type=accept and evt.dir=">" and fd.port=443 to see only incoming HTTPS connections to nginx processes, with zero ambiguity.

Container visibility works because Sysdig hooks into the kernel below the container abstraction layer. When Docker or Kubernetes launches a container, they're just creating Linux namespaces and cgroups. Sysdig captures the syscalls that establish these primitives, then correlates every subsequent syscall with its originating container by examining the process's cgroup membership. This means you can filter by container.name or kubernetes.pod.name without any agent running inside the container—the visibility comes from kernel-level observation:

# See all file opens across all containers
sudo sysdig -pc evt.type=open

# Filter to a specific Kubernetes pod
sudo sysdig -pk8s.pod.name=frontend-7d4b8 "fd.type=file and evt.type in (open,close)"

# Monitor network connections by container with chisel
sudo csysdig -vcontainers

The trace file capability (-w flag) deserves emphasis because it fundamentally changes incident response. Traditional tools give you a live stream—once an event passes, it's gone unless you were capturing it. Sysdig lets you record everything (or filtered subsets to manage size), then replay captures with different filters. Imagine capturing 10 minutes of production traffic during a mystery slowdown, then spending hours exploring it with different queries: "Show me all disk I/O by this process. Now show network calls. Now show mutex operations." The full system context is preserved, including timing relationships between processes.

Under the hood, the kernel module uses tracepoint hooks on syscall entry and exit points. Each syscall generates an enter event (direction ">") and an exit event (direction "<"), letting you measure latency by subtracting timestamps. The eBPF implementation uses BPF programs attached to the same tracepoints but runs in the kernel's verified sandbox, eliminating the risk of kernel panics from driver bugs—though with some performance overhead compared to the native module.

Gotcha

The kernel module requirement is sysdig's Achilles heel for adoption. Many cloud providers, locked-down production environments, and security-conscious organizations prohibit loading custom kernel modules. While the eBPF probe addresses this concern, it requires kernel 4.14+ with specific configurations, and some managed Kubernetes platforms disable even eBPF for user workloads. You might find yourself unable to use sysdig precisely in the environments where you need it most. Additionally, building the kernel module requires kernel headers matching your running kernel version—a surprisingly painful requirement in immutable infrastructure where nodes are disposable and kernel headers aren't pre-installed.

Performance overhead is the second major gotcha. Capturing every syscall on a busy system generates massive data volumes—we're talking gigabytes per minute on high-throughput applications. Even with filters applied at capture time, the kernel module still processes every syscall before filtering. In benchmarks, sysdig can consume 10-20% CPU on busy systems, and ring buffer overflows will cause event drops during traffic spikes. The trace files grow shockingly fast; a production web server might generate several GB of capture data in minutes. This makes "always-on" production recording impractical, limiting sysdig to time-bounded troubleshooting sessions or environments where you can accept the overhead. The learning curve is real too—the filtering syntax is powerful but dense, and knowing which of the 100+ included chisels solves your specific problem takes experience.

Verdict

Use if: You're troubleshooting complex, intermittent issues in containerized environments where you need complete system visibility and the ability to replay events for deep analysis. Sysdig excels when standard monitoring shows symptoms but you need to understand root causes at the syscall level—tracking down file descriptor leaks, diagnosing container networking issues, or understanding exactly how applications interact with databases and filesystems. It's invaluable for security incident response when you need a forensic timeline of what happened. Skip if: You're in a locked-down production environment without kernel module support, need continuous low-overhead monitoring (use Prometheus/Grafana instead), or are just getting started with basic observability (master standard metrics and logs first). Also skip if you're purely focused on application-level tracing—OpenTelemetry and APM tools provide better developer experience for distributed tracing without kernel dependencies.

// ADD TO YOUR README
[![Featured on Starlog](https://starlog.is/api/badge/developer-tools/draios-sysdig.svg)](https://starlog.is/api/badge-click/developer-tools/draios-sysdig)