analysis

package
v2.0.16+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 15, 2021 License: GPL-3.0 Imports: 9 Imported by: 10

Documentation

Overview

Package analysis implements heuristical frequency analysis of Psiphon Tunnel Core server logs. Log lines are parsed into 3 distinct log types: message, metrics and unknown. Under these log types the number of logs of each unique identifier is counted. The unique identifiers are as follows: message: "msg" field metrics: "event_name" field unknown: key graph

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseLogModel

type BaseLogModel struct {
	Example string
	Node    node
}

func (*BaseLogModel) JsonString

func (a *BaseLogModel) JsonString() string

func (*BaseLogModel) Print

func (a *BaseLogModel) Print(printStructure, printExample bool)

type LogFields

type LogFields logrus.Fields

type LogLevel

type LogLevel int
const (
	LOG_LEVEL_UNKNOWN          = -1
	LOG_LEVEL_DEBUG   LogLevel = iota
	LOG_LEVEL_INFO
	LOG_LEVEL_WARNING
	LOG_LEVEL_ERROR
)

func (LogLevel) String

func (l LogLevel) String() string

type LogModel

type LogModel interface {
	JsonString() string
	Print(bool, bool)
}

type LogModelStats

type LogModelStats struct {
	Count uint
}

type LogModelStatsMetrics

type LogModelStatsMetrics interface {
	NumLogs() uint
}

type LogStats

type LogStats struct {
	MessageLogModels MessageLogStats
	MetricsLogModels MetricsLogStats
	UnknownLogModels UnknownLogStats
}

func NewLogStats

func NewLogStats() (l *LogStats)

NewLogStats initializes a new LogStats structure.

func NewLogStatsFromFiles

func NewLogStatsFromFiles(files []string) (l *LogStats, err error)

func (*LogStats) NumDistinctLogs

func (l *LogStats) NumDistinctLogs() uint

NumDistinctLogs returns the number of unique log models contained within the LogStats structure.

func (*LogStats) ParseFile

func (l *LogStats) ParseFile(filename string) error

ParseFile takes a psiphond log file as input, parses the log lines into log models and updates the LogStats structure.

func (*LogStats) ParseLogLine

func (l *LogStats) ParseLogLine(log string) error

ParseLogLine attempts to parse a log line into a log model and then updates the LogStats structure.

func (*LogStats) Print

func (l *LogStats) Print(messages, metrics, unknown, printStructure, printExample bool)

func (*LogStats) SortLogModels

func (l *LogStats) SortLogModels(messages, metrics, unknown bool) (models []interface{}, numLogs uint)

sortLogModelsDescending merges all log models of different types and then sorts them in ascending order by the number times each occurs. Returns the sorted list and the total number of logs represented by each log model in the list.

type LogTypeStats

type LogTypeStats struct {
	Count uint
}

type MessageLogContext

type MessageLogContext string

type MessageLogError

type MessageLogError string

type MessageLogKey

type MessageLogKey string

type MessageLogModel

type MessageLogModel struct {
	BaseLogModel
	Msg               MessageLogName
	Level             LogLevel
	MessageLogContext *MessageLogContext
	MessageLogError   *MessageLogError
}

func (*MessageLogModel) Print

func (a *MessageLogModel) Print(printStructure, printExample bool)

type MessageLogModelStats

type MessageLogModelStats struct {
	LogModelStats
	MessageLogModel
}

func (MessageLogModelStats) NumLogs

func (a MessageLogModelStats) NumLogs() uint

func (*MessageLogModelStats) Print

func (a *MessageLogModelStats) Print(printStructure, printExample bool)

func (*MessageLogModelStats) PrintWithRelativePercent

func (a *MessageLogModelStats) PrintWithRelativePercent(count uint, printStructure, printExample bool)

type MessageLogName

type MessageLogName string

type MessageLogStats

type MessageLogStats struct {
	LogTypeStats
	// contains filtered or unexported fields
}

func (*MessageLogStats) Print

func (a *MessageLogStats) Print()

func (*MessageLogStats) Sort

type MetricsLogEventName

type MetricsLogEventName string

type MetricsLogModel

type MetricsLogModel struct {
	BaseLogModel
	Event MetricsLogEventName
}

func (*MetricsLogModel) Print

func (a *MetricsLogModel) Print(printStructure, printExample bool)

type MetricsLogModelStats

type MetricsLogModelStats struct {
	LogModelStats
	MetricsLogModel
}

func (MetricsLogModelStats) NumLogs

func (a MetricsLogModelStats) NumLogs() uint

func (*MetricsLogModelStats) Print

func (a *MetricsLogModelStats) Print(printStructure, printExample bool)

func (*MetricsLogModelStats) PrintWithRelativePercent

func (a *MetricsLogModelStats) PrintWithRelativePercent(count uint, printStructure, printExample bool)

type MetricsLogStats

type MetricsLogStats struct {
	LogTypeStats
	// contains filtered or unexported fields
}

func (*MetricsLogStats) Print

func (a *MetricsLogStats) Print()

func (*MetricsLogStats) Sort

type UnknownLogModel

type UnknownLogModel struct {
	BaseLogModel
}

func (*UnknownLogModel) Print

func (a *UnknownLogModel) Print(printStructure, printExample bool)

type UnknownLogModelStats

type UnknownLogModelStats struct {
	LogModelStats
	UnknownLogModel
}

func (UnknownLogModelStats) NumLogs

func (a UnknownLogModelStats) NumLogs() uint

func (*UnknownLogModelStats) Print

func (a *UnknownLogModelStats) Print(printExample bool)

func (*UnknownLogModelStats) PrintWithRelativePercent

func (a *UnknownLogModelStats) PrintWithRelativePercent(count uint, printExample bool)

type UnknownLogStats

type UnknownLogStats struct {
	LogTypeStats
	// contains filtered or unexported fields
}

func (*UnknownLogStats) Print

func (a *UnknownLogStats) Print()

func (*UnknownLogStats) Sort

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL