LogViewer
A modern log viewer with AI-assisted analysis (Qt 6)
Loading...
Searching...
No Matches
ui::qt::PatternAnalysisPanel Class Reference

Panel for detecting recurring structures and correlations across log events. More...

#include <PatternAnalysisPanel.hpp>

Inheritance diagram for ui::qt::PatternAnalysisPanel:
Inheritance graph
Collaboration diagram for ui::qt::PatternAnalysisPanel:
Collaboration graph

Public Slots

void Refresh ()
 Recompute all analyses from the current visible event set.
 

Signals

void TemplateSelected (std::vector< unsigned long > matchingIndices)
 

Public Member Functions

 PatternAnalysisPanel (db::EventsContainer &events, EventsTableView *eventsView, QWidget *parent=nullptr)
 

Private Member Functions

void BuildLayout ()
 
void RefreshTemplates (const std::vector< unsigned long > &indices)
 
void RefreshCooccurrence (const std::vector< unsigned long > &indices)
 
void RefreshNgrams (const std::vector< unsigned long > &indices)
 
std::vector< unsigned long > VisibleIndices () const
 

Static Private Member Functions

static std::vector< std::string > Tokenise (const std::string &text)
 Tokenise text on whitespace and common delimiters.
 
static std::vector< std::string > MergeTokens (const std::vector< std::string > &a, const std::vector< std::string > &b)
 Merge two token sequences into a template; differing tokens → "{*}".
 
static QString RenderTemplate (const std::vector< std::string > &tokens)
 Render a token sequence back to a human-readable string.
 

Private Attributes

db::EventsContainer & m_events
 
EventsTableView * m_eventsView
 
QTabWidget * m_tabs {nullptr}
 
QComboBox * m_msgFieldCombo {nullptr}
 Which field to use as "message".
 
QTableWidget * m_templateTable {nullptr}
 
QSpinBox * m_windowSpin {nullptr}
 Time-window size in seconds.
 
QTableWidget * m_coocTable {nullptr}
 
QComboBox * m_ngramSizeCombo {nullptr}
 Bigram / Trigram selector.
 
QSpinBox * m_ngramTopNSpin {nullptr}
 How many top n-grams to display.
 
QTableWidget * m_ngramTable {nullptr}
 
std::vector< std::vector< unsigned long > > m_templateMatches
 
DrillDownFilter m_templateFilter
 The events-view filter set by the last template click.
 

Detailed Description

Panel for detecting recurring structures and correlations across log events.

Three analysis modes, all scoped to the currently visible (filtered) event set:

1. Message Templates
Extracts the common skeleton of log messages: constant tokens are kept as-is, variable tokens are replaced with {*}. Clicking a template row filters the events table to the matching events.

Algorithm (simplified Drain-inspired):

  • Events are grouped by their type-field value.
  • Within each group the message field is tokenised on whitespace / punctuation.
  • Tokens that differ across instances of the same template are replaced with {*}.
2. Co-occurrence (Correlation)
Shows pairs of event-type values that frequently appear within the same configurable time window. Result is a table sorted by co-occurrence count descending. Useful for spotting causal chains: e.g. "ERROR X is almost always preceded within 2 s by WARNING Y".
3. Sequence N-grams
Extracts the sequence of event-type values in chronological order and counts bigrams and trigrams. The most frequent patterns reveal standard operating procedures, boot sequences, or anomalous repetitions.

Refreshes automatically via MainWindow::modelReset signal.

Constructor & Destructor Documentation

◆ PatternAnalysisPanel()

ui::qt::PatternAnalysisPanel::PatternAnalysisPanel ( db::EventsContainer &  events,
EventsTableView *  eventsView,
QWidget *  parent = nullptr 
)
explicit
Here is the call graph for this function:

Member Function Documentation

◆ BuildLayout()

void ui::qt::PatternAnalysisPanel::BuildLayout ( )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ MergeTokens()

std::vector< std::string > ui::qt::PatternAnalysisPanel::MergeTokens ( const std::vector< std::string > &  a,
const std::vector< std::string > &  b 
)
staticprivate

Merge two token sequences into a template; differing tokens → "{*}".

◆ Refresh

void ui::qt::PatternAnalysisPanel::Refresh ( )
slot

Recompute all analyses from the current visible event set.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ RefreshCooccurrence()

void ui::qt::PatternAnalysisPanel::RefreshCooccurrence ( const std::vector< unsigned long > &  indices)
private
Here is the call graph for this function:

◆ RefreshNgrams()

void ui::qt::PatternAnalysisPanel::RefreshNgrams ( const std::vector< unsigned long > &  indices)
private
Here is the call graph for this function:

◆ RefreshTemplates()

void ui::qt::PatternAnalysisPanel::RefreshTemplates ( const std::vector< unsigned long > &  indices)
private
Here is the call graph for this function:

◆ RenderTemplate()

QString ui::qt::PatternAnalysisPanel::RenderTemplate ( const std::vector< std::string > &  tokens)
staticprivate

Render a token sequence back to a human-readable string.

◆ TemplateSelected

void ui::qt::PatternAnalysisPanel::TemplateSelected ( std::vector< unsigned long >  matchingIndices)
signal

Emitted when the user clicks a template row, after the events view was filtered to the matching events (their indices).

Here is the caller graph for this function:

◆ Tokenise()

std::vector< std::string > ui::qt::PatternAnalysisPanel::Tokenise ( const std::string &  text)
staticprivate

Tokenise text on whitespace and common delimiters.

◆ VisibleIndices()

std::vector< unsigned long > ui::qt::PatternAnalysisPanel::VisibleIndices ( ) const
private

Member Data Documentation

◆ m_coocTable

QTableWidget* ui::qt::PatternAnalysisPanel::m_coocTable {nullptr}
private

◆ m_events

db::EventsContainer& ui::qt::PatternAnalysisPanel::m_events
private

◆ m_eventsView

EventsTableView* ui::qt::PatternAnalysisPanel::m_eventsView
private

◆ m_msgFieldCombo

QComboBox* ui::qt::PatternAnalysisPanel::m_msgFieldCombo {nullptr}
private

Which field to use as "message".

◆ m_ngramSizeCombo

QComboBox* ui::qt::PatternAnalysisPanel::m_ngramSizeCombo {nullptr}
private

Bigram / Trigram selector.

◆ m_ngramTable

QTableWidget* ui::qt::PatternAnalysisPanel::m_ngramTable {nullptr}
private

◆ m_ngramTopNSpin

QSpinBox* ui::qt::PatternAnalysisPanel::m_ngramTopNSpin {nullptr}
private

How many top n-grams to display.

◆ m_tabs

QTabWidget* ui::qt::PatternAnalysisPanel::m_tabs {nullptr}
private

◆ m_templateFilter

DrillDownFilter ui::qt::PatternAnalysisPanel::m_templateFilter
private

The events-view filter set by the last template click.

◆ m_templateMatches

std::vector<std::vector<unsigned long> > ui::qt::PatternAnalysisPanel::m_templateMatches
private

◆ m_templateTable

QTableWidget* ui::qt::PatternAnalysisPanel::m_templateTable {nullptr}
private

◆ m_windowSpin

QSpinBox* ui::qt::PatternAnalysisPanel::m_windowSpin {nullptr}
private

Time-window size in seconds.


The documentation for this class was generated from the following files: