aurae-runtime / auraed

Secure mTLS and gRPC backed runtime daemon. Alternative to systemd. Written in Rust.
https://aurae.io/auraed
Apache License 2.0
60 stars 11 forks source link

Kernel logging #20

Open MalteJ opened 1 year ago

MalteJ commented 1 year ago

We should expose Kernel logging via the API, so it can be picked up by a client. As we will also need stdout and stderr streams of all processes auraed is spawning, it would probably be wise to use the same logging pipeline also for Kernel logs.

We can use klogctl to collect Kernel logs.

krisnova commented 1 year ago

So part of the scope for auraed will be executing processes natively on the host. which means whatever we use for kernel logs we should also use for process logs.

Right now I believe we will be using

std::process::Command::Spawn()

the spawn() function which returns a child which has subsequent stdin, stdout, and stderr streams embedded.

This means that we have direct access to the file descriptor for each spawned process natively in Rust 🎉.

I believe we can write a new rust module/crate/pipeline/muxer/router (I am hesitant to call it a "bus" for obvious reasons) which can be used to "route" kernel logs as well as the stderr and stdout read from the file descriptor from each spawned process.

We have a 3rd type of log we need to consider in the logging system which is the (old name bpf_printk) bpf_trace_printk kernel logs.

Note: The BPF subsystem logs to /sys/kernel/tracing/trace_pipe by default which will require /sys to be mounted before we can log.

cat /sys/kernel/tracing/trace_pipe

We can write the logging system in Rust, however it will likely have yet-another depending on libc which I am still coming to terms with emotionally.

I am not opposed to writing the logger in C and providing bindings for Rust.