pub struct LogGroup {
pub id: Uuid,
pub variables: HashMap<usize, Token>,
/* private fields */
}Expand description
Represents a logical grouping of similar log records.
A LogGroup is characterized by a base event (a Record) and a collection
of example records that match the group’s pattern. It also tracks variables
(wildcards) within the log pattern.
Fields§
§id: UuidThe unique identifier for this log group.
variables: HashMap<usize, Token>A map of variable positions (offset) to their Token type within the event pattern.
Implementations§
Source§impl LogGroup
impl LogGroup
Sourcepub fn add_example(&mut self, rec: Record)
pub fn add_example(&mut self, rec: Record)
Adds a new example Record to the log group.
This method also attempts to discover new variables (wildcards) by comparing the new record with the group’s base event and updates the group’s variable map.
§Arguments
rec- TheRecordto add as an example.
Sourcepub fn event(&self) -> &Record
pub fn event(&self) -> &Record
Returns a reference to the base event (Record) of this log group.
This record represents the generalized pattern of the log group.
§Returns
A reference to the Record that is the base event.
Sourcepub fn base_record(&self) -> &Record
pub fn base_record(&self) -> &Record
Returns a reference to the base record of the log group.
This is an alias for event().
§Returns
A reference to the Record that is the base record.
Sourcepub fn examples(&self) -> &Vec<Record>
pub fn examples(&self) -> &Vec<Record>
Returns a slice of the example records stored in this log group.
These are the actual log lines that have been clustered into this group.
§Returns
A slice (&Vec<Record>) of the example records.
Sourcepub fn discover_variables(&self, rec: &Record) -> Result<Vec<Wildcard>, Error>
pub fn discover_variables(&self, rec: &Record) -> Result<Vec<Wildcard>, Error>
Compares a given Record with the log group’s base event to identify variable positions.
Positions where the tokens differ between the record and the base event, and are not already identified as variables, are considered new variables.
§Arguments
rec- TheRecordto compare against the base event.
§Returns
A Result containing a Vec<Wildcard> representing the newly discovered
variable positions, or an anyhow::Error if the comparison fails.
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the total number of example records stored in this LogGroup.
§Returns
The number of examples as a usize.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Checks if the log group contains any example records.
§Returns
true if the log group has no examples, false otherwise.
Sourcepub fn get_examples(&self) -> Vec<&Record>
pub fn get_examples(&self) -> Vec<&Record>
Returns a vector of references to the example records for this group.
§Returns
A Vec<&Record> containing references to all example records.
Trait Implementations§
Source§impl Display for LogGroup
impl Display for LogGroup
Source§fn fmt(&self, f: &mut Formatter<'_>) -> Result
fn fmt(&self, f: &mut Formatter<'_>) -> Result
Formats the LogGroup for display.
This implementation provides a human-readable summary of the log group, including its ID, first seen timestamp, base event, number of examples, and number of wildcards.
§Arguments
f- The formatter to write into.
§Returns
A fmt::Result indicating success or failure of the formatting operation.
Auto Trait Implementations§
impl Freeze for LogGroup
impl RefUnwindSafe for LogGroup
impl Send for LogGroup
impl Sync for LogGroup
impl Unpin for LogGroup
impl UnsafeUnpin for LogGroup
impl UnwindSafe for LogGroup
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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