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 (and pipelines) without blocking in-flight event processing.

Builds a fresh RuntimeEngine with the same configuration as the current one, re-reads pipeline files from disk (if paths are set), 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.

If pipeline or rule loading fails, the old engine remains active.

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> AnyExt for T
where T: Any + ?Sized,

Source§

fn downcast_ref<T>(this: &Self) -> Option<&T>
where T: Any,

Attempts to downcast this to T behind reference
Source§

fn downcast_mut<T>(this: &mut Self) -> Option<&mut T>
where T: Any,

Attempts to downcast this to T behind mutable reference
Source§

fn downcast_rc<T>(this: Rc<Self>) -> Result<Rc<T>, Rc<Self>>
where T: Any,

Attempts to downcast this to T behind Rc pointer
Source§

fn downcast_arc<T>(this: Arc<Self>) -> Result<Arc<T>, Arc<Self>>
where T: Any,

Attempts to downcast this to T behind Arc pointer
Source§

fn downcast_box<T>(this: Box<Self>) -> Result<Box<T>, Box<Self>>
where T: Any,

Attempts to downcast this to T behind Box pointer
Source§

fn downcast_move<T>(this: Self) -> Option<T>
where T: Any, Self: Sized,

Attempts to downcast owned Self to T, useful only in generic context as a workaround for specialization
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> Chain<T> for T

Source§

fn len(&self) -> usize

The number of items that this chain link consists of.
Source§

fn append_to(self, v: &mut Vec<T>)

Append the elements in this link to the chain.
Source§

impl<T, X> CoerceTo<T> for X
where T: CoerceFrom<X> + ?Sized,

Source§

fn coerce_rc_to(self: Rc<X>) -> Rc<T>

Source§

fn coerce_box_to(self: Box<X>) -> Box<T>

Source§

fn coerce_ref_to(&self) -> &T

Source§

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

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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. 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