in_etw: Implement event tracing for windows input plugin#12072
in_etw: Implement event tracing for windows input plugin#12072cosmo0920 wants to merge 5 commits into
Conversation
Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughThis PR adds a new Windows ETW input plugin, ChangesETW input plugin
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant FluentBitCore as Fluent Bit Core
participant InEtwPlugin as in_etw plugin
participant WorkerThread as ETW worker thread
participant ETWSession as Windows ETW session
participant TDH as TDH API
FluentBitCore->>InEtwPlugin: in_etw_init()
InEtwPlugin->>InEtwPlugin: validate config and build session state
InEtwPlugin->>WorkerThread: start worker thread
WorkerThread->>ETWSession: StartTraceW / EnableTraceEx2 / OpenTraceW
WorkerThread->>ETWSession: ProcessTrace()
ETWSession-->>WorkerThread: ETW event callback
WorkerThread->>TDH: TdhGetEventInformation / TdhGetProperty
TDH-->>WorkerThread: property values
WorkerThread->>FluentBitCore: flb_input_log_append(record)
WorkerThread->>ETWSession: ControlTraceW(query loss metrics)
WorkerThread->>FluentBitCore: update ETW loss gauges
FluentBitCore->>InEtwPlugin: in_etw_pause / in_etw_resume / in_etw_exit
InEtwPlugin->>WorkerThread: stop or restart trace processing
InEtwPlugin->>ETWSession: close session and trace handles
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 846e9dd510
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
|
Is this similar to https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/receiver/windowseventlogreceiver ? (per my read of this PR it seems it ships the signal as a log, should we use ctraces ? -- open for discussion) |
Description
This is a parity plugin of in_ebpf which is targeted for Windows platforms.
This is because there's no plugins to retrieve system level of traces on Windows platforms.
Windows platforms have Event Tracing for Windows component to provide system level tracing that is a similar mechanism of tracing Kernel side of events which are a part of capabilities of Linux's eBPF.
This is somewhat useful to diagnose system level of traces.
Add Windows ETW system logger support to
event_tracing_windows.This extends the input into two explicit modes:
session_type provider: existing real-time ETW provider consumer path usingprovider_nameorprovider_guid.session_type system: Windows kernel/system logger path usingkernel_flags,the
SystemTraceControlGuidvalue, andEVENT_TRACE_SYSTEM_LOGGER_MODE.This is ETW-based collection, not Windows Event Log channel collection. The
correct positioning is:
Behavior
System mode:
[INPUT] Name event_tracing_windows session_type system kernel_flags process,thread,image_loaduses the Windows kernel logger session:
and configures the session through
EVENT_TRACE_PROPERTIESwith:EnableTraceEx2()is skipped in system mode because kernel logger events areenabled by session flags, not by enabling one provider GUID.
Provider-specific options are rejected in system mode:
because system mode consumes multiple kernel providers rather than one
configured provider.
Validation
Build:
Confirm config map exposes the new options:
Confirm invalid system session names are rejected early:
Expected result:
Confirm non-elevated behavior:
Expected result from a non-Administrator shell:
Confirm elevated kernel collection from an Administrator shell:
Expected result:
The input starts successfully and emits records from the Windows kernel logger:
Example observed output:
Image-load events may appear when matching activity occurs, for example:
Image-load payloads are not required as the only success condition; kernel
logger output depends on the enabled flags and runtime activity during the test
window.
Compatibility Notes
Provider mode remains the default:
Existing configurations using
provider_nameorprovider_guidcontinue to usethe normal real-time provider consumer path.
Both modes require Administrator privileges on Windows because the plugin starts
and controls ETW real-time trace sessions:
System mode is additionally constrained to the Windows kernel logger session
name:
A non-elevated shell can fail with:
where
status=5isERROR_ACCESS_DENIED.Enter
[N/A]in the box, if an item is not applicable to your change.Testing
Before we can approve your change; please submit the following in a comment:
If this is a change to packaging of containers or native binaries then please confirm it works for all targets.
ok-package-testlabel to test for all targets (requires maintainer to do).Documentation
Backporting
Fluent Bit is licensed under Apache 2.0, by submitting this pull request I understand that this code will be released under the terms of that license.
Summary by CodeRabbit