eBPF
지원 이벤트 유형:
logs참고 — 이 플러그인은 실험적이라 불안정할 수 있어요. 개발이나 테스트 환경에서만 사용하도록 해요. 기능과 동작이 바뀔 수 있어요.
in_ebpf 입력 플러그인은 eBPF(extended Berkeley Packet Filter)를 사용해 저수준 시스템 이벤트를 수집해요. 이 플러그인을 쓰면 Fluent Bit가 프로세스 실행, 파일 접근, 메모리 할당, 네트워크 연결, 시그널 처리 같은 커널 레벨 활동을 모니터링할 수 있어요. 디버깅, 모니터링, 보안 분석을 위한 시스템 동작에 대한 유용한 인사이트를 제공해 줘요.
in_ebpf 플러그인은 eBPF를 활용해 커널 이벤트를 실시간으로 추적해요. 트레이스 포인트를 지정하면 대상이 되는 시스템 레벨 메트릭과 이벤트를 수집할 수 있어서, 운영체제 상호작용과 성능 특성을 들여다볼 수 있게 돼요.
출처: 문서
본문
구성 파라미터
이 플러그인은 다음 구성 파라미터를 지원해요.
| Key | Description | Default |
|---|---|---|
poll_ms |
Set the polling interval in milliseconds for collecting events from the ring buffer. | 1000 |
ringbuf_map_name |
Set the name of the eBPF ring buffer map to read events from. | events |
trace |
Set the eBPF trace to enable (for example, trace_bind, trace_dns, trace_exec, trace_malloc, trace_openssl, trace_sched, trace_signal, trace_tcp, trace_vfs). This parameter can be set multiple times to enable multiple traces. |
none |
시스템 종속성
in_ebpf를 활성화하려면 시스템에 다음 종속성이 설치되어 있어야 해요.
- 커널 버전: 4.18 이상, eBPF 지원이 활성화되어 있어야 함.
- 필요한 패키지:
bpftool: eBPF 프로그램을 관리하고 디버깅하는 데 사용.libbpf-dev: eBPF 프로그램을 로드하고 상호작용하기 위한libbpf라이브러리 제공.- CMake 3.13 이상: 플러그인 빌드에 필요.
Ubuntu에 종속성 설치하기
sudo apt update
sudo apt install libbpf-dev linux-tools-common cmake
in_ebpf와 함께 Fluent Bit 빌드하기
in_ebpf 플러그인을 활성화하려면 다음 단계에 따라 Fluent Bit를 소스에서 빌드해요.
-
Fluent Bit 저장소를 클론해요.
git clone https://github.com/fluent/fluent-bit.git cd fluent-bit -
in_ebpf로 빌드를 구성해요.빌드 디렉터리를 만들고
-DFLB_IN_EBPF=On플래그와 함께cmake를 실행해서in_ebpf플러그인을 활성화해요.mkdir build cd build cmake .. -DFLB_IN_EBPF=On -
소스를 컴파일해요.
make -
Fluent Bit를 실행해요.
상승된 권한(예:
sudo)으로 Fluent Bit를 실행해요. eBPF 프로그램을 로드하려면 root 접근 권한이나 적절한 권한이 필요해요.# For YAML configuration. sudo fluent-bit --config fluent-bit.yaml # For classic configuration. sudo fluent-bit --config fluent-bit.conf
구성 예시
플러그인을 구성하는 기본 예시는 다음과 같아요.
fluent-bit.yaml:
pipeline:
inputs:
- name: ebpf
poll_ms: 500
trace:
- trace_signal
- trace_malloc
- trace_bind
fluent-bit.conf:
[INPUT]
Name ebpf
Poll_Ms 500
Trace trace_signal
Trace trace_malloc
Trace trace_bind
이 구성은 다음을 추적하도록 활성화해요.
- 시그널 처리 이벤트 (
trace_signal) - 메모리 할당 이벤트 (
trace_malloc) - 네트워크 bind 작업 (
trace_bind)
설정에 Trace 지시어를 여러 개 추가하면 여러 트레이스를 활성화할 수 있어요. 기존 트레이스의 전체 목록은 여기에서 볼 수 있어요: Fluent Bit eBPF Traces
출력 필드
각 트레이스는 공통 필드와 트레이스별 필드를 가진 레코드를 만들어요.
공통 필드
모든 트레이스는 다음 필드를 포함해요.
| Field | Description |
|---|---|
event_type |
Type of event (signal, malloc, bind, exec, tcp, vfs, tls_handshake, tls_read, tls_write, or tls_shutdown). |
event_id |
Per-CPU monotonic identifier for the event. |
pid |
Process ID that generated the event. |
tid |
Thread ID that generated the event. |
comm |
Command name (process name) that generated the event. |
시그널 트레이스 필드
trace_signal 트레이스는 다음 추가 필드를 포함해요.
| Field | Description |
|---|---|
signal |
Signal number that was sent. |
tpid |
Target process ID that received the signal. |
메모리 트레이스 필드
trace_malloc 트레이스는 다음 추가 필드를 포함해요.
| Field | Description |
|---|---|
operation |
Memory operation type (for example, 0 = malloc, 1 = free, 2 = calloc, 3 = realloc). |
address |
Memory address of the operation. |
size |
Size of the memory operation in bytes. |
Bind 트레이스 필드
trace_bind 트레이스는 다음 추가 필드를 포함해요.
| Field | Description |
|---|---|
uid |
User ID of the process. |
gid |
Group ID of the process. |
port |
Port number the socket is binding to. |
bound_dev_if |
Network device interface the socket is bound to. |
error_raw |
Error code for the bind operation (0 indicates success). |
TCP 트레이스 필드
trace_tcp 트레이스는 TCP 연결 수명 주기 이벤트를 캡처하고 다음 추가 필드를 포함해요.
| Field | Description |
|---|---|
event_type |
TCP event subtype (listen, accept, or connect). |
fd |
File descriptor for the socket. |
backlog |
Listen backlog size (for listen events). |
new_fd |
New file descriptor returned by the kernel (for accept events). |
peer_port |
Remote peer port number (for accept events). |
peer_addr |
Remote peer IP address (for accept events). |
remote_port |
Remote port number (for connect events). |
remote_addr |
Remote IP address (for connect events). |
error_raw |
Error code for the operation (0 indicates success). |
VFS 트레이스 필드
trace_vfs 트레이스는 다음 추가 필드를 포함해요.
| Field | Description |
|---|---|
operation |
VFS operation type (integer). |
path |
File path involved in the operation. |
flags |
Flags passed to the VFS operation. |
mode |
File mode bits for the operation. |
fd |
File descriptor returned by the operation. |
error_raw |
Error code for the operation (0 indicates success). |
Exec 트레이스 필드
trace_exec 트레이스는 다음 추가 필드를 포함해요.
| Field | Description |
|---|---|
stage |
Execution stage. One of enter, exit, or unknown. |
ppid |
Parent process ID. |
filename |
Path of the executable being run. |
argv |
First argument of the command (argv[0]). |
argv1 |
Second argument of the command (argv[1]). |
argv2 |
Third argument of the command (argv[2]). |
argv_last |
Final captured argument when more than three are present. |
argc |
Total number of arguments. |
error_raw |
Error code for the operation (0 indicates success). |
DNS 트레이스 필드
trace_dns 트레이스는 DNS 쿼리와 응답 이벤트를 캡처하고 다음 추가 필드를 포함해요.
| Field | Description |
|---|---|
error_raw |
Error code for the operation (0 indicates success). |
latency_ns |
Round-trip latency in nanoseconds between query and response. |
query |
Resolved DNS query name (for example, example.com). |
query_type |
Numeric DNS query type (for example, 1 for IPv4 address (A record), 28 for IPv6 address (AAAA record)). |
rcode |
DNS response code (0 indicates no error). |
response |
Set to 1 if the record is a DNS response; 0 if it's a query. |
txid |
DNS transaction ID. |
Sched 트레이스 필드
trace_sched 트레이스는 CPU 스케줄링 전환 이벤트를 캡처하고 다음 추가 필드를 포함해요.
| Field | Description |
|---|---|
cpu |
CPU that ran the scheduling switch. |
prev_pid |
Process ID of the task being scheduled out. |
prev_prio |
Priority of the task being scheduled out. |
prev_state |
Kernel task state of the task being scheduled out. |
next_pid |
Process ID of the task being scheduled in. |
next_prio |
Priority of the task being scheduled in. |
runq_latency_ns |
Run-queue latency in nanoseconds between wakeup and scheduling in (0 when not tracked). |
wakeup_tracked |
Set to true when a matching wakeup was tracked for the run-queue latency calculation. |
OpenSSL 트레이스 필드
trace_openssl 트레이스는 사용자 공간 프로브(user-space probes)를 사용해 OpenSSL TLS 작업을 캡처하고 다음 추가 필드를 포함해요.
| Field | Description |
|---|---|
trace |
OpenSSL operation. One of openssl_tls_read, openssl_tls_write, openssl_tls_shutdown, or openssl_tls_handshake. |
ssl_ptr |
Pointer to the OpenSSL SSL object associated with the operation. |
latency_ns |
Operation latency in nanoseconds. |
ret |
Return value of the OpenSSL call. |