Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // Utf16leEOL is the bytes sequence for UTF-16 Little-Endian end-of-line char Utf16leEOL = []byte{'\n', 0x00} // Utf16beEOL is the bytes sequence for UTF-16 Big-Endian end-of-line char Utf16beEOL = []byte{0x00, '\n'} )
Functions ¶
This section is empty.
Types ¶
type AutoMultilineHandler ¶
type AutoMultilineHandler struct {
// contains filtered or unexported fields
}
AutoMultilineHandler can attempts to detect a known/commob pattern (a timestamp) in the logs and will switch to a MultiLine handler if one is detected and the thresholds are met.
func NewAutoMultilineHandler ¶
func NewAutoMultilineHandler(outputChan chan *Message, lineLimit, linesToAssess int, matchThreshold float64, matchTimeout time.Duration, flushTimeout time.Duration, source *logsconfig.LogSource, additionalPatterns []*regexp.Regexp, detectedPattern *DetectedPattern, ) *AutoMultilineHandler
NewAutoMultilineHandler returns a new AutoMultilineHandler.
func (*AutoMultilineHandler) Handle ¶
func (h *AutoMultilineHandler) Handle(input *Message)
Handle puts all new lines into a channel for later processing.
func (*AutoMultilineHandler) Start ¶
func (h *AutoMultilineHandler) Start()
Start starts the handler.
type BytesSequenceMatcher ¶
type BytesSequenceMatcher struct {
// contains filtered or unexported fields
}
BytesSequenceMatcher defines the criterion to whether to end a line based on an arbitrary byte sequence
func NewBytesSequenceMatcher ¶
func NewBytesSequenceMatcher(sequence []byte) *BytesSequenceMatcher
NewBytesSequenceMatcher Returns a new matcher based on custom bytes sequence
func (*BytesSequenceMatcher) Match ¶
Match returns true whenever it finds a matching sequence at the end of append(exists, appender[start:end+1])
func (*BytesSequenceMatcher) SeparatorLen ¶
func (b *BytesSequenceMatcher) SeparatorLen() int
SeparatorLen return the number of byte to ignore
type DecodedInput ¶
type DecodedInput struct {
// contains filtered or unexported fields
}
DecodedInput represents a decoded line and the raw length
func NewDecodedInput ¶
func NewDecodedInput(content []byte, rawDataLen int) *DecodedInput
NewDecodedInput returns a new decoded input.
type Decoder ¶
type Decoder struct { InputChan chan *Input OutputChan chan *Message // contains filtered or unexported fields }
Decoder splits raw data into lines and passes them to a lineParser that passes them to a lineHandler that emits outputs Input->[decoder]->[parser]->[handler]->Message
func InitializeDecoder ¶
InitializeDecoder returns a properly initialized Decoder
func New ¶
func New(InputChan chan *Input, OutputChan chan *Message, lineParser LineParser, contentLenLimit int, matcher EndLineMatcher, detectedPattern *DetectedPattern) *Decoder
New returns an initialized Decoder
func NewDecoderWithEndLineMatcher ¶
func NewDecoderWithEndLineMatcher(source *config.LogSource, parser parser.Parser, matcher EndLineMatcher, multiLinePattern *regexp.Regexp) *Decoder
NewDecoderWithEndLineMatcher initialize a decoder with given endline strategy.
func (*Decoder) GetDetectedPattern ¶
GetDetectedPattern returns a detected pattern (if any)
func (*Decoder) GetLineCount ¶
GetLineCount returns the number of decoded lines
type DetectedPattern ¶
DetectedPattern is a container to safely access a detected multiline pattern
func (*DetectedPattern) Set ¶
func (d *DetectedPattern) Set(pattern *regexp.Regexp)
Set sets the pattern
type EndLineMatcher ¶
type EndLineMatcher interface { // Match takes the existing bytes and the bytes to be appended, returns // true if the combination matches the end of line condition. Match(exists []byte, appender []byte, start int, end int) bool SeparatorLen() int }
EndLineMatcher defines the criterion to whether to end a line or not.
type Input ¶
type Input struct {
// contains filtered or unexported fields
}
Input represents a chunk of line.
type LineHandler ¶
type LineHandler interface { Handle(input *Message) Start() Stop() }
LineHandler handles raw lines to form structured lines
type LineParser ¶
type LineParser interface { Handle(input *DecodedInput) Start() Stop() }
LineParser e
type Message ¶
type Message struct { Content []byte Status string RawDataLen int Timestamp string IngestionTimestamp int64 }
Message represents a structured line.
type MultiLineHandler ¶
type MultiLineHandler struct {
// contains filtered or unexported fields
}
MultiLineHandler makes sure that multiple lines from a same content are properly put together.
func NewMultiLineHandler ¶
func NewMultiLineHandler(outputChan chan *Message, newContentRe *regexp.Regexp, flushTimeout time.Duration, lineLimit int) *MultiLineHandler
NewMultiLineHandler returns a new MultiLineHandler.
func (*MultiLineHandler) Handle ¶
func (h *MultiLineHandler) Handle(input *Message)
Handle forward lines to lineChan to process them.
type MultiLineParser ¶
type MultiLineParser struct {
// contains filtered or unexported fields
}
MultiLineParser makes sure that chunked lines are properly put together.
func NewMultiLineParser ¶
func NewMultiLineParser(flushTimeout time.Duration, parser parser.Parser, lineHandler LineHandler, lineLimit int) *MultiLineParser
NewMultiLineParser returns a new MultiLineParser.
func (*MultiLineParser) Handle ¶
func (p *MultiLineParser) Handle(input *DecodedInput)
Handle forward lines to lineChan to process them.
type NewLineMatcher ¶
type NewLineMatcher struct {
EndLineMatcher
}
NewLineMatcher implements EndLineMatcher for line ending with '\n'
func (*NewLineMatcher) SeparatorLen ¶
func (n *NewLineMatcher) SeparatorLen() int
SeparatorLen returns the length of the line separator
type SingleLineHandler ¶
type SingleLineHandler struct {
// contains filtered or unexported fields
}
SingleLineHandler takes care of tracking the line length and truncating them when they are too long.
func NewSingleLineHandler ¶
func NewSingleLineHandler(outputChan chan *Message, lineLimit int) *SingleLineHandler
NewSingleLineHandler returns a new SingleLineHandler.
func (*SingleLineHandler) Handle ¶
func (h *SingleLineHandler) Handle(input *Message)
Handle puts all new lines into a channel for later processing.
type SingleLineParser ¶
type SingleLineParser struct {
// contains filtered or unexported fields
}
SingleLineParser makes sure that multiple lines from a same content are properly put together.
func NewSingleLineParser ¶
func NewSingleLineParser(parser parser.Parser, lineHandler LineHandler) *SingleLineParser
NewSingleLineParser returns a new SingleLineParser.
func (*SingleLineParser) Handle ¶
func (p *SingleLineParser) Handle(input *DecodedInput)
Handle puts all new lines into a channel for later processing.