models

package
v0.0.0-...-0a9e301 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ResolveRule

func ResolveRule(contents *logs.LogFile, rule *Rule, logger *logrus.Logger) (*library.RuleData, error)

Types

type Configuration

type Configuration struct {
	Name  string `json:"name"`
	Rules []Rule `json:"rules"`
}

A Configuration struct represents the top level of a JSON configuration file. It has two elements, Name (The type of file to be resolved), and Rules.

func CreateConfiguration

func CreateConfiguration(source string) (config *Configuration, err error)

func (*Configuration) TranslateConfiguration

func (config *Configuration) TranslateConfiguration() error

Translates any regex groups with names from (?<name>) syntax to (?P<name>) for Processing in Go

type ConfigurationSource

type ConfigurationSource struct {
	// contains filtered or unexported fields
}

func (*ConfigurationSource) SetSource

func (configSource *ConfigurationSource) SetSource(source string)

func (*ConfigurationSource) SetSourceType

func (configSource *ConfigurationSource) SetSourceType(sourceType string)

func (*ConfigurationSource) Source

func (configSource *ConfigurationSource) Source() string

func (*ConfigurationSource) SourceType

func (configSource *ConfigurationSource) SourceType() string

type FileSource

type FileSource struct {
	ConfigurationSource
}

func (*FileSource) Config

func (config *FileSource) Config() ([]byte, error)

type IConfigurationSource

type IConfigurationSource interface {
	SetSourceType(sourceType string)
	SetSource(source string)
	SourceType() string
	Source() string
	Config() ([]byte, error)
}

func NewFileSource

func NewFileSource(source string) IConfigurationSource

func NewWebSource

func NewWebSource(source string) IConfigurationSource

func Source

func Source(source string) (IConfigurationSource, error)

type Rule

type Rule struct {
	Name        string   `json:"name"`
	PrintLog    bool     `json:"printLog"`
	SearchTerms []string `json:"searchTerms"`
	Summary     []string `json:"summary"`
}

A Rule Struct represents different pieces of data that need to be found in a log file. "Name" should describe what the utility should be looking for. "PrintLog" should describe whether a line should be printed out after it resolved to a search term in the rule.

"SearchTerms" a list of regular expressions that the rule should look for. SearchTerms can save information resolved from a regex using a named group (?<group_name>). SearchTerms can also reference data saved from named groups with {{rule_name[group_name]}}

The summary is a list of strings that should be printed out at the end of log file analysis. These can implement the same naming conventions to reference data as SearchTerms. They can also implement their own data manipulation functions such as {{Count(rule_name[group_name])}} to count the number of instances of <group_name> in that rule.

type WebSource

type WebSource struct {
	ConfigurationSource
}

func (*WebSource) Config

func (config *WebSource) Config() ([]byte, error)

Jump to

Keyboard shortcuts

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