sources

package
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventMatchSelectorFirst = "first"
	EventMatchSelectorLast  = "last"
	EventMatchSelectorAll   = "all"
)

Match Selector consts for an Event's MatchSelector

Variables

This section is empty.

Functions

func CommentMatchedLine added in v0.1.7

func CommentMatchedLine() func(matchedLine string) string

CommentMatchedLine is a helper func that returns a func that can be used as a CommentFunc in an Event The func will use the matched line as the comment

Types

type CommentFunc added in v0.1.7

type CommentFunc func(matchedLine string) string

type Event added in v0.1.7

type Event struct {
	Name          string      `json:"name"`
	Metric        string      `json:"metric"`
	MatchSelector string      `json:"matchSelector"`
	Terminal      bool        `json:"terminal"`
	SrcName       string      `json:"src"`
	Src           Source      `json:"-"`
	CommentFn     CommentFunc `json:"-"`
	FindFn        FindFunc    `json:"-"`
}

Event defines what is being timed from a specific source

type FindFunc added in v0.1.7

type FindFunc func(s Source, log []byte) ([]string, error)

type FindResult added in v0.1.7

type FindResult struct {
	Line      string
	Timestamp time.Time
	Comment   string
	Err       error
}

FindResult is all data associated with a find including the raw Line data

func SelectMatches added in v0.1.7

func SelectMatches(results []FindResult, matchSelector string) []FindResult

SelectMaches will filter raw results based on the provided matchSelector

type LogReader

type LogReader struct {
	Path            string
	Glob            bool
	TimestampRegex  *regexp.Regexp
	TimestampLayout string
	// contains filtered or unexported fields
}

LogReader is a base Source helper that can Read file contents, cache, and support Glob file paths Other Sources can be built on-top of the LogSrc

func (*LogReader) ClearCache

func (l *LogReader) ClearCache()

ClearCache cleas the cached log

func (*LogReader) Find

func (l *LogReader) Find(re *regexp.Regexp) ([]string, error)

Find searches for the passed in regexp from the log references in the LogReader

func (*LogReader) ParseTimestamp added in v0.1.7

func (l *LogReader) ParseTimestamp(line string) (time.Time, error)

ParseTimestamp usese the configured timestamp regex to find a timestamp from the passed in log line and return as a time.Time

func (*LogReader) Read

func (l *LogReader) Read() ([]byte, error)

Read will open and read all the bytes of a log file into byte slice and then cache it Any further calls to Read() will use the cached byte slice. If the file is being updated and you need the updated contents, you'll need to instantiate a new LogSrc and call Read() again

type Source

type Source interface {
	// Find finds the string in the source using a source specific method (could be regex or HTTP path)
	// If no time.Time could be found an error is returned
	Find(event *Event) ([]FindResult, error)
	// Name is the source name identifier
	Name() string
	// ClearCache clears any cached source data
	ClearCache()
	// String is a human friendly version of the source, usually the log filepath
	String() string
}

Source is an interface representing a source of events which have a time stamp or latency associated with them. Most often source is a log file or an API.

type Timing added in v0.1.7

type Timing struct {
	Event     *Event        `json:"event"`
	Timestamp time.Time     `json:"timestamp"`
	T         time.Duration `json:"seconds"`
	Comment   string        `json:"comment"`
	Error     error         `json:"error"`
}

Timing is a specific instance of an Event timing

Directories

Path Synopsis
Package awsnode is a latency timing source for the VPC CNI logs (aka aws-node DaemonSet)
Package awsnode is a latency timing source for the VPC CNI logs (aka aws-node DaemonSet)
Package ec2 is a latency timing source for ec2 API events
Package ec2 is a latency timing source for ec2 API events
Package imds is a latency timing source for the EC2 Instance Metadata Service (IMDS)
Package imds is a latency timing source for the EC2 Instance Metadata Service (IMDS)
Package k8s is a latency timing source for K8s API events
Package k8s is a latency timing source for K8s API events
Package messages is a latency timing source for /var/log/messages
Package messages is a latency timing source for /var/log/messages

Jump to

Keyboard shortcuts

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