timegrinder

package module
v3.2.2+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2019 License: BSD-2-Clause Imports: 6 Imported by: 12

Documentation

Overview

ANSIC = "Mon Jan _2 15:04:05 2006"

Index

Constants

View Source
const (
	AnsiC            int = iota
	Unix             int = iota
	Ruby             int = iota
	RFC822           int = iota
	RFC822Z          int = iota
	RFC850           int = iota
	RFC1123          int = iota
	RFC1123Z         int = iota
	RFC3339          int = iota
	RFC3339Nano      int = iota
	Apache           int = iota
	ApacheNoTz       int = iota
	Syslog           int = iota
	SyslogFile       int = iota
	SyslogFileTZ     int = iota
	DPKG             int = iota
	Custom1Milli     int = iota
	NGINX            int = iota
	UnixMilli        int = iota
	ZonelessRFC3339  int = iota
	SyslogVariant    int = iota
	UnpaddedDateTime int = iota
	UnixMs           int = iota
	UnixNano         int = iota
)
View Source
const (
	DEFAULT_TIMEGRINDER_SIZE int = 16

	APACHE_FORMAT            string = `_2/Jan/2006:15:04:05 -0700`
	APACHE_NO_TZ_FORMAT      string = `_2/Jan/2006:15:04:05`
	NGINX_FORMAT             string = `2006/01/02 15:04:05`
	SYSLOG_FORMAT            string = `Jan _2 15:04:05`
	SYSLOG_FILE_FORMAT       string = `2006-01-02T15:04:05.999999999-07:00`
	SYSLOG_FILE_FORMAT_TZ2   string = `2006-01-02T15:04:05.999999999-0700`
	DPKG_MSG_FORMAT          string = `2006-01-02 15:04:05`
	CUSTOM1_MILLI_MSG_FORMAT string = `01-02-2006 15:04:05.0`
	ZONELESS_RFC3339_FORMAT  string = `2006-01-02T15:04:05.999999999`
	SYSLOG_VARIANT           string = `Jan 02 2006 15:04:05`
	UNPADDED_DATE_TIME       string = `2006-1-2 15:04:05`
)

Variables

This section is empty.

Functions

func FormatDirective deprecated

func FormatDirective(s string) (v int, err error)

FormatDirective tkes a string and attempts to match it against a case insensitive format directive This function is useful in taking string designations for time formats, checking if they are valid and converting them to an iota int for overriding the timegrinder

Deprecated: The directive string should be entirely handled by an initialized timegrinder

func NewAnsiCProcessor

func NewAnsiCProcessor() *processor

func NewApacheNoTZProcessor

func NewApacheNoTZProcessor() *processor

func NewApacheProcessor

func NewApacheProcessor() *processor

func NewCustom1MilliProcessor

func NewCustom1MilliProcessor() *processor

func NewDPKGProcessor

func NewDPKGProcessor() *processor

func NewNGINXProcessor

func NewNGINXProcessor() *processor

func NewRFC1123Processor

func NewRFC1123Processor() *processor

func NewRFC1123ZProcessor

func NewRFC1123ZProcessor() *processor

func NewRFC3339NanoProcessor

func NewRFC3339NanoProcessor() *processor

func NewRFC3339Processor

func NewRFC3339Processor() *processor

func NewRFC822Processor

func NewRFC822Processor() *processor

func NewRFC822ZProcessor

func NewRFC822ZProcessor() *processor

func NewRFC850Processor

func NewRFC850Processor() *processor

func NewRubyProcessor

func NewRubyProcessor() *processor

func NewSyslogFileProcessor

func NewSyslogFileProcessor() *processor

func NewSyslogFileProcessorTZ2

func NewSyslogFileProcessorTZ2() *processor

func NewSyslogProcessor

func NewSyslogProcessor() *syslogProcessor

func NewSyslogVariant

func NewSyslogVariant() *processor

func NewUnixMilliTimeProcessor

func NewUnixMilliTimeProcessor() *unixProcessor

func NewUnixMsTimeProcessor

func NewUnixMsTimeProcessor() *unixMsProcessor

We assume you're not ingesting data from 1970, so we look for at least 13 digits of nanoseconds

func NewUnixNanoTimeProcessor

func NewUnixNanoTimeProcessor() *unixNanoProcessor

We assume you're not ingesting data from 1970, so we look for at least 16 digits of nanoseconds

func NewUnixProcessor

func NewUnixProcessor() *processor

func NewUnpaddedDateTime

func NewUnpaddedDateTime() *processor

func NewUserProcessor

func NewUserProcessor(name, rxps, fmts string) (*processor, error)

func NewZonelessRFC3339

func NewZonelessRFC3339() *processor

func ValidateFormatOverride

func ValidateFormatOverride(s string) (err error)

Types

type Config

type Config struct {
	//force TimeGrinder to scan all possible formats on first entry, seeding with left most
	//We assume that most streams are not going to using a bunch of different timestamps
	//so we take the hit on the first iteration to try to get the left most time format
	EnableLeftMostSeed bool
	FormatOverride     string
}

type Processor

type Processor interface {
	Extract([]byte, *time.Location) (time.Time, bool, int)
	Match([]byte) (int, int, bool)
	Format() string
	ToString(time.Time) string
	ExtractionRegex() string
	Name() string
}

func NewUK

func NewUK() Processor

type TimeGrinder

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

func New

func New(c Config) (*TimeGrinder, error)

New constructs and returns a new TimeGrinder object * On error, it will return a nil and error variable * The TimeGrinder object is completely safe for concurrent use.

func NewTimeGrinder

func NewTimeGrinder(c Config) (*TimeGrinder, error)

NewTimeGrinder just calls New, it is maintained for API compatability but may go away soon. Use New.

func (*TimeGrinder) AddProcessor

func (tg *TimeGrinder) AddProcessor(p Processor) (idx int, err error)

func (*TimeGrinder) DebugExtract

func (tg *TimeGrinder) DebugExtract(data []byte) (t time.Time, offset int, err error)

DebugExtract returns a time, offset, and error. If no time was extracted, the offset is -1

Error indicates a catastrophic failure.

func (*TimeGrinder) Extract

func (tg *TimeGrinder) Extract(data []byte) (t time.Time, ok bool, err error)

Extract returns time and error. If no time can be extracted time is the zero

value and bool is false.  Error indicates a catastrophic failure.

func (*TimeGrinder) Match

func (tg *TimeGrinder) Match(data []byte) (start, end int, ok bool)

Match identifies where in a byte array a properly formatted timestamp could be

and returns the indexes in the data slice of that format.  It DOES NOT attempt to parse
the timestamp.  This is a faster way to say "a tiestamp could be here"
ok is always true on successful match

func (*TimeGrinder) OverrideProcessor

func (tg *TimeGrinder) OverrideProcessor() (Processor, error)

func (*TimeGrinder) SetLocalTime

func (tg *TimeGrinder) SetLocalTime()

func (*TimeGrinder) SetTimezone

func (tg *TimeGrinder) SetTimezone(f string) error

func (*TimeGrinder) SetUTC

func (tg *TimeGrinder) SetUTC()

Jump to

Keyboard shortcuts

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