Documentation ¶
Index ¶
Constants ¶
const ( KlogRegex = `\d{4} \d{2}:\d{2}:\d{2}.\d{6}` EtcdRegex = `"ts":"\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z"` RancherRegex = `^\d{4}/\d{2}/\d{2} \d{2}:\d{2}:\d{2}` JournaldRegex = `^[A-Z][a-z]{2} \d{1,2} \d{2}:\d{2}:\d{2}` RancherLayout = "2006/01/02 15:04:05" KlogLayout = "0102 15:04:05.999999 MST 2006" JournaldLayout = "Jan 02 15:04:05 MST 2006" )
const ( EtcdTimestampRegex = `^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}.\d{6}` EtcdTimestampLayout = "2006-01-02 15:04:05.999999Z07:00" RFC3339Milli = "2006-01-02T15:04:05.999Z07:00" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DateParser ¶
type DateParser interface {
ParseTimestamp(log string) (time.Time, string, bool) // Parse timestamp should have the implementation for parsing the timestamp from a log line
}
DateParser is an interface for parsing the timestamp from a log line It returns the datetime, the log line, and a boolean indicating if the datetime was found
func NewDayMonthParser ¶
func NewDayMonthParser(datetimeRegex string, layout string, opts ...DayMonthOption) DateParser
type Dateformat ¶
type DayMonthOption ¶
type DayMonthOption func(*dayMonthOptions)
func WithInnerDateRegex ¶
func WithInnerDateRegex(regex string) DayMonthOption
func WithStripOuterDate ¶
func WithStripOuterDate() DayMonthOption
func WithTimezone ¶
func WithTimezone(timezone string) DayMonthOption
func WithYear ¶
func WithYear(year string) DayMonthOption
type DayMonthParser ¶
type DayMonthParser struct {
// contains filtered or unexported fields
}
DayMonthParser will parse a timestamp string without a year and timezone into a datetime given the regex and layout of the timestamp. It will also optionally strip the outer date and detect if the remaining text contains a valid date
func (*DayMonthParser) ParseTimestamp ¶
type DockerParser ¶
type DockerParser struct {
TimestampRegex string
}
DockerParser will parse logs with a default ISO8601 timestamp. It is expected that there will be two timestamps
func (*DockerParser) ParseTimestamp ¶
type EtcdJSONLog ¶
type MultipleParser ¶
type MultipleParser struct { Dateformats []Dateformat StripLeadingDate bool }
Multiple parser will parse logs with multiple date formats and optionally strip the leading date.
func (*MultipleParser) ParseTimestamp ¶
type RKE2EtcdParser ¶
type RKE2EtcdParser struct{}
RKE2EtcdParser will parse etcd logs for RKE2. These logs can either be in json or plain text.