data

package
v0.0.0-...-bc1244e Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2024 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LogVerdictUnknown int = iota
	LogVerdictHam
	LogVerdictSpam
	LogVerdictNothing
	NumLogVerdicts
)

Variables

View Source
var (
	ErrHashNotFound = errors.New("specified hash not found")
	ErrRuleNotFound = errors.New("specified rule not found")
	ErrNoSource     = errors.New("source has not been specified")
)

Functions

func LogMatchesRule

func LogMatchesRule(log *Log, rule *LogRule) bool

func LogRuleToVerdict

func LogRuleToVerdict(rule *LogRule) int

func LogVerdict

func LogVerdict(log *Log, rules []*LogRule) int

func LogVerdictToString

func LogVerdictToString(verdict int) string

func SortedKeys

func SortedKeys[K cmp.Ordered, V any](m map[string]V) []string

func SortedKeysWithFunc

func SortedKeysWithFunc[K comparable, V any](m map[K]V, cmp func(a, b K) int) []K

func UnmarshalJSONFromPath

func UnmarshalJSONFromPath(target any, path string) error

Types

type ArraySource

type ArraySource struct {
	Data  []*Log
	Chunk int
	// contains filtered or unexported fields
}

func (*ArraySource) Load

func (self *ArraySource) Load() ([]*Log, error)

type BulkRuleMatcher

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

func NewBulkRuleMatcher

func NewBulkRuleMatcher(rules []*LogRule) *BulkRuleMatcher

func (*BulkRuleMatcher) ToRule

func (self *BulkRuleMatcher) ToRule(log *Log) *LogRule

type Database

type Database struct {
	// This mutex guards log rules and logs; configuration is assumed to be static
	sync.Mutex

	// Where is this file saved
	Path   string    `json:"-"`
	Source LogSource `json:"-"`

	LogRules LogRules
	// contains filtered or unexported fields
}

func (*Database) Add

func (self *Database) Add(r LogRule) error

func (*Database) AddOrUpdate

func (self *Database) AddOrUpdate(rule LogRule) error

func (*Database) ClassifyHash

func (self *Database) ClassifyHash(hash uint64, ham bool) error

func (*Database) Delete

func (self *Database) Delete(rid int) error

func (*Database) Load

func (self *Database) Load() error

func (*Database) LogCount

func (self *Database) LogCount() int

func (*Database) Logs

func (self *Database) Logs() ([]*Log, error)

func (*Database) RuleCount

func (self *Database) RuleCount(rid int) int

type Log

type Log struct {
	Timestamp  int64
	Time       time.Time
	Stream     map[string]string
	StreamKeys []string
	Fields     map[string]interface{}
	FieldsKeys []string
	Message    string
	RawMessage string
	// contains filtered or unexported fields
}

func NewLog

func NewLog(timestamp int64, stream map[string]string, data string) *Log

func (*Log) Hash

func (self *Log) Hash() uint64

func (*Log) IDString

func (self *Log) IDString() string

func (*Log) MatchesFTS

func (self *Log) MatchesFTS(search string) bool

func (*Log) ToRule

func (self *Log) ToRule(rules *LogRules) *LogRule

type LogFieldMatcher

type LogFieldMatcher struct {
	Field string
	Op    string
	Value string
	// contains filtered or unexported fields
}

func (*LogFieldMatcher) Match

func (self *LogFieldMatcher) Match(s string) bool

func (*LogFieldMatcher) MatchesFTS

func (self *LogFieldMatcher) MatchesFTS(s string) bool

type LogRule

type LogRule struct {
	// Id zero is reserved 'not saved'
	ID int

	// Rule may or may not be disabled
	Disabled bool

	// Is the result interesting, or not?
	Ham bool

	// List of matchers the rule matches against
	Matchers []LogFieldMatcher

	// Comment (if any)
	Comment string

	// Version of the rule; any time the rule is changed, the
	// version is incremented
	Version int
}

func LogToRule

func LogToRule(log *Log, rules []*LogRule) *LogRule

func (*LogRule) MatchesFTS

func (self *LogRule) MatchesFTS(search string) bool

func (*LogRule) SourceString

func (self *LogRule) SourceString() string

type LogRules

type LogRules struct {
	Rules   []*LogRule
	Version int

	// Reversed rules - these are always available if Rules are
	Reversed []*LogRule `json:"-"`
	// contains filtered or unexported fields
}

func NewLogRules

func NewLogRules(rules []*LogRule, version int) LogRules

type LogSource

type LogSource interface {
	Load() ([]*Log, error)
}

type LokiQueryResult

type LokiQueryResult struct {
	Status string               `json:"status"`
	Data   *LokiQueryResultData `json:"data"`
}

type LokiQueryResultData

type LokiQueryResultData struct {
	ResultType string                      `json:"resultType"`
	Result     []LokiQueryResultDataResult `json:"result"`
}

type LokiQueryResultDataResult

type LokiQueryResultDataResult struct {
	Metric map[string]string `json:"metric"`
	Stream map[string]string `json:"stream"`
	Values [][]string        `json:"values"`
}

type LokiSource

type LokiSource struct {
	Server   string
	Selector string
	// contains filtered or unexported fields
}

func (*LokiSource) Load

func (self *LokiSource) Load() ([]*Log, error)

Jump to

Keyboard shortcuts

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