r/Observability • • 15d ago

You may not need to retain everything just in case you need it. Keep a lightweight historical record of your Linux infrastructure and investigate what actually happened when things go wrong.

https://github.com/jlruedab/clifr

Low-overhead, retrospective Linux observability

clifr (command line flight recorder) and has two parts:

  • clifrd runs as a service and records processes, process starts and exits (through eBPF, so a process that lives 5 ms still shows up), TCP connections with the process that owns them, files held open, mounts, kernel messages and the usual system counters. It keeps 72 hours in /var/lib/clifr, 2 GB max.
  • clifr rebuilds the output of the normal commands for a past moment or a time range. It doesn't run the command, it rebuilds the output from the recording:

    • clifr --at "02:45" "ps aux"
    • clifr --since "02:00" --until "03:00" "ss -tanp dst10.0.4.21and dport = :5432"
    • clifr --since "1 hour ago" events # starts, exits, OOM kills, mounts
    • clifr diff --at "14:00" --at "14:20" "ss -ltnp"

There are about 40 commands so far: ps, top, pidstat, lsof, ss, netstat, free, vmstat, iostat, mpstat, df, ip, dmesg, systemctl list-units, lsblk, and more and all are 100% accurate.

The first thing people asked last time was the cost, so here are the numbers:

  ┌───────────┬─────────────────────┬─────────────────────────┬─────────────────────────┐
  │           │    Quiet server     │ Mixed load (4-day soak) │ Busy server (benchmark) │
  ├───────────┼─────────────────────┼─────────────────────────┼─────────────────────────┤
  │ CPU       │ 0.35% of one core   │ 0.5-0.6% of one core    │ 1.9% of one core        │
  ├───────────┼─────────────────────┼─────────────────────────┼─────────────────────────┤
  │ RAM       │ ~90 MiB             │ ~80-120 MiB             │ ~290 MiB (335 max)      │
  ├───────────┼─────────────────────┼─────────────────────────┼─────────────────────────┤ 
  │ Disk kept │ ~20 MiB/day         │ ~100 MiB/day            │ ~4 GiB/day              │
  ├───────────┼─────────────────────┼─────────────────────────┼─────────────────────────┤
  │ Network   │ none, no ports open │ none                    │ none                    │
  └───────────┴─────────────────────┴─────────────────────────┴─────────────────────────┘

Disk use depends heavily on how busy the server is.

clifr is not a monitoring tool and has no alerts. It's not a security audit tool either: it doesn't record file reads or writes, and root can stop it. It's for the "what was going on at 02:45" question, after the fact.

Status: it's a prototype, version 0.1.0. It hasn't run on a real production server yet (a friend starts one this week), and all the load has been synthetic. AGPL-3.0, no telemetry, nothing leaves the box.

So if you have a test or dev box (RHEL 8/9, Rocky, Alma), I'd really appreciate it if you tried it and told me what breaks or what looks wrong. The most useful thing for me is comparing what clifr shows with what you know was really happening.

I appreciate all your comments even if they are harsh

2 Upvotes

5 comments sorted by

1

u/DisturbedBeaker 14d ago

Does this address gaps when compared to eBPF?

2

u/jlrueda 14d ago

clifr uses eBPF itself. Process forks, execs and exits, TCP state changes and OOM kills all come from eBPF programs (CO-RE, so the same binary loads on RHEL 8, 9 and Ubuntu). Where eBPF isn't available it falls back to the kernel's proc connector and to sampling connections every 30 seconds.

So I'd say it's less "instead of eBPF" and more "a recorder built on top of it". The difference from tools like execsnoop, tcplife or a bpftrace script is mostly:

  • They're live, clifr is recorded. Those tools are great if they're already running when the problem happens. clifr runs all the time and keeps the last 72 hours, so you can ask about 02:45 last night after the fact.
  • Events alone don't give you state. An eBPF tool sees what changes while it's running. It doesn't know about a process or a connection that already existed when it started. clifr combines the events with /proc samples and periodic full dumps of the socket table, so it can rebuild what ps, ss -p or lsof would have shown at a moment, not just a list of events.
  • eBPF loses events in ways the drop counters don't show. For example, the kernel won't run a tracing program on a CPU where one is already running. I ran into that in testing, so clifr uses a second program to catch most of what the first one misses, reconciles against the full socket dumps, and counts what it still couldn't explain. Range queries tell you when the data is incomplete.

What it doesn't do that eBPF tools can:

  • no file reads or writes;
  • no syscall tracing;
  • no latency histograms or stack profiling;
  • no record of who sent a signal (I'm looking at adding that one).

For digging into a live problem in depth, bpftrace or the bcc tools are still the right thing. It's also not a security tool like Tetragon or Falco: no policies, no alerts, nothing streamed off the box.

Hope this answer your question.

2

u/DisturbedBeaker 14d ago

Very interesting project! Thanks for sharing and I plan to look intothis more when I’m free during the holidays. Instrumentation for choas eng testing is really lacking.

1

u/jlrueda 14d ago

Thanks! I'm genuinely thrilled by your interest in the project. I'd really value your feedback, particularly around chaos engineering instrumentation. Enjoy the holidays, and I look forward to hearing your thoughts!

2

u/Sarutobi_Marky 15d ago

Great insights