Skip to main content

LogProcessor

Struct LogProcessor 

Source
pub struct LogProcessor { /* private fields */ }
Expand description

Thread-safe handle to the engine, swappable atomically for hot-reload.

Uses ArcSwap<Mutex<RuntimeEngine>> so that:

  • Detection + correlation processing can acquire &mut RuntimeEngine via the inner Mutex.
  • Hot-reload swaps the entire engine atomically without blocking in-flight batches (they hold an Arc to the old engine until their batch completes).

Implementations§

Source§

impl LogProcessor

Source

pub fn new(engine: RuntimeEngine, metrics: Arc<dyn MetricsHook>) -> Self

Create a new processor wrapping the given engine and metrics hook.

Source

pub fn swap_engine(&self, new_engine: RuntimeEngine)

Atomically replace the engine with a new one.

In-flight batches continue against the old engine (they hold an Arc snapshot). New batches see the replacement on their next call to process_batch_lines.

Source

pub fn engine_snapshot(&self) -> Guard<Arc<Mutex<RuntimeEngine>>>

Load a snapshot of the current engine for use during reload.

The caller can lock the returned guard to export state, build a new engine, import state, and then call swap_engine.

Source

pub fn process_batch_lines( &self, batch: &[String], event_filter: &EventFilter, ) -> Vec<ProcessResult>

Process a batch of raw input lines through the engine.

  1. Parses each line as JSON; on error, increments parse error metrics.
  2. Applies the event_filter closure to extract payloads.
  3. Evaluates all payloads via RuntimeEngine::process_batch.
  4. Merges per-payload results back into per-line results.
  5. Updates metrics (events processed, latency, match counts).

Returns one ProcessResult per input line.

Source

pub fn process_batch_with_format( &self, batch: &[String], format: &InputFormat, event_filter: Option<&EventFilter>, ) -> Vec<ProcessResult>

Process a batch of raw input lines using the specified input format.

Unlike process_batch_lines, this method supports all input formats (JSON, syslog, plain, logfmt, CEF). The event_filter only applies to JSON-decoded events (it extracts multiple payloads from one JSON object, e.g. a records[] array). Non-JSON formats produce exactly one event per line.

Returns one ProcessResult per input line.

Source

pub fn reload_rules(&self) -> Result<EngineStats, String>

Reload rules without blocking in-flight event processing.

Builds a fresh RuntimeEngine with the same configuration as the current one, loads rules into it, imports the old engine’s correlation state, and atomically swaps. In-flight batches that already hold an Arc to the old engine finish undisturbed.

Source

pub fn rules_path(&self) -> PathBuf

Return the rules path from the current engine.

Source

pub fn metrics(&self) -> &dyn MetricsHook

Return a reference to the metrics hook.

Source

pub fn export_state(&self) -> Option<CorrelationSnapshot>

Export correlation state from the current engine.

Source

pub fn import_state(&self, snapshot: &CorrelationSnapshot) -> bool

Import correlation state into the current engine.

Source

pub fn stats(&self) -> EngineStats

Return summary statistics about the current engine.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more