Documentation ¶
Index ¶
- Constants
- Variables
- func IsDigit(c byte) bool
- func Parse2Digits(bs []byte, min int, max int, e error) ([]byte, int, error)
- func ParseHostname(bs []byte) ([]byte, string)
- func ParseTag(bs []byte) ([]byte, string)
- func ParseTimestamp(bs []byte) ([]byte, time.Time, error)
- func ParseVersion(bs []byte) ([]byte, int, error)
- func ShowCursorPos(buff []byte, cursor int)
- func ValidFormat(format string) bool
- type Collector
- type Event
- type Facility
- type LogParser
- type NetstrDelimiter
- type Parser
- type ParserError
- type Priority
- type RFC5424V2
- type Severity
- type SyslogDelimiter
- type TCPCollector
- type UDPCollector
Constants ¶
const ( PRI_PART_START = '<' PRI_PART_END = '>' NO_VERSION = -1 )
const (
NILVALUE = '-'
)
const (
// SYSLOG_DELIMITER indicates the start of a syslog line
SYSLOG_DELIMITER = `<[0-9]{1,3}>[0-9]\s`
)
Variables ¶
var ( ErrEOL = &ParserError{"End of log line"} ErrNoSpace = &ParserError{"No space found"} ErrPriorityNoStart = &ParserError{"No start char found for priority"} ErrPriorityEmpty = &ParserError{"Priority field empty"} ErrPriorityNoEnd = &ParserError{"No end char found for priority"} ErrPriorityTooShort = &ParserError{"Priority field too short"} ErrPriorityTooLong = &ParserError{"Priority field too long"} ErrPriorityNonDigit = &ParserError{"Non digit found in priority"} ErrVersionNotFound = &ParserError{"Can not find version"} ErrTimestampUnknownFormat = &ParserError{"Timestamp format unknown"} )
var ( ErrYearInvalid = &ParserError{"Invalid year in timestamp"} ErrMonthInvalid = &ParserError{"Invalid month in timestamp"} ErrDayInvalid = &ParserError{"Invalid day in timestamp"} ErrHourInvalid = &ParserError{"Invalid hour in timestamp"} ErrMinuteInvalid = &ParserError{"Invalid minute in timestamp"} ErrSecondInvalid = &ParserError{"Invalid second in timestamp"} ErrSecFracInvalid = &ParserError{"Invalid fraction of second in timestamp"} ErrTimeZoneInvalid = &ParserError{"Invalid time zone in timestamp"} ErrInvalidTimeFormat = &ParserError{"Invalid time format"} ErrInvalidAppName = &ParserError{"Invalid app name"} ErrInvalidProcId = &ParserError{"Invalid proc ID"} ErrInvalidMsgId = &ParserError{"Invalid msg ID"} ErrNoStructuredData = &ParserError{"No structured data"} )
Functions ¶
func ParseHostname ¶
func ParseTimestamp ¶
ParseTimestamp https://tools.ietf.org/html/rfc3164#section-4.1.2
func ParseVersion ¶
func ShowCursorPos ¶
func ValidFormat ¶
ValidFormat returns if the given format matches one of the possible formats.
Types ¶
type Collector ¶
Collector specifies the interface all network collectors must implement.
func NewCollector ¶
NewCollector returns a network collector of the specified type, that will bind to the given inteface on Start(). If config is non-nil, a secure Collector will be returned. Secure Collectors require the protocol be TCP.
type Event ¶
type Event struct { Text string // Delimited log line Parsed map[string]interface{} // If non-nil, contains parsed fields ReceptionTime time.Time // Time log line was received Sequence int64 // Provides order of reception SourceIP string // Sender's IP address // contains filtered or unexported fields }
Event is a log message, with a reception timestamp and sequence number.
func (*Event) ReferenceTime ¶
ReferenceTime returns the reference time of an event.
type LogParser ¶
type LogParser struct { Raw []byte Result map[string]interface{} // contains filtered or unexported fields }
A Parser parses the raw input as a map with a timestamp field.
func NewLogParser ¶
NewParser returns a new Parser instance.
type NetstrDelimiter ¶
type NetstrDelimiter struct { Result string // contains filtered or unexported fields }
A NetstrDelimiter detects when message lines start.
func NewNetstrDelimiter ¶
func NewNetstrDelimiter() *NetstrDelimiter
NewNetstrDelimiter returns an initialized NetstrDelimiter.
func (*NetstrDelimiter) Push ¶
func (d *NetstrDelimiter) Push(b byte) (bool, error)
Push the given byte into a buffer, return when a new result is available, as well as the first occurring error (if any occurred).
func (*NetstrDelimiter) Reset ¶
func (d *NetstrDelimiter) Reset()
Reset the NetstrDelimiter instance to its initial state.
type Parser ¶
func CreateParser ¶
type ParserError ¶
type ParserError struct {
ErrorString string
}
func (*ParserError) Error ¶
func (err *ParserError) Error() string
type Priority ¶
func ParsePriority ¶
type RFC5424V2 ¶
type RFC5424V2 struct {
// contains filtered or unexported fields
}
RFC5424V2 represents a parser for RFC5424V2-compliant log messages
type SyslogDelimiter ¶
type SyslogDelimiter struct {
// contains filtered or unexported fields
}
A SyslogDelimiter detects when Syslog lines start.
func NewSyslogDelimiter ¶
func NewSyslogDelimiter(maxSize int) *SyslogDelimiter
NewSyslogDelimiter returns an initialized SyslogDelimiter.
func (*SyslogDelimiter) Push ¶
func (s *SyslogDelimiter) Push(b byte) (string, bool)
Push a byte into the SyslogDelimiter. If the byte results in a a new Syslog message, it'll be flagged via the bool.
func (*SyslogDelimiter) Vestige ¶
func (s *SyslogDelimiter) Vestige() (string, bool)
Vestige returns the bytes which have been pushed to SyslogDelimiter, since the last Syslog message was returned, but only if the buffer appears to be a valid syslog message.
type TCPCollector ¶
type TCPCollector struct {
// contains filtered or unexported fields
}
TCPCollector represents a network collector that accepts and handler TCP connections.
func (*TCPCollector) Addr ¶
func (s *TCPCollector) Addr() net.Addr
Addr returns the net.Addr that the Collector is bound to, in a race-say manner.
type UDPCollector ¶
type UDPCollector struct {
// contains filtered or unexported fields
}
UDPCollector represents a network collector that accepts UDP packets.
func (*UDPCollector) Addr ¶
func (s *UDPCollector) Addr() net.Addr
Addr returns the net.Addr to which the UDP collector is bound.