Documentation ¶
Overview ¶
Package parser supports transforming raw log "lines" into messages with some associated metadata (timestamp, severity, etc.).
This parsing comes after "line parsing" (breaking input into multiple lines) and before further processing and aggregation of log messages.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Noop *noop
Noop is the default parser and simply returns lines unchanged as messages
Functions ¶
This section is empty.
Types ¶
type DockerStreamFormat ¶
type DockerStreamFormat struct {
// contains filtered or unexported fields
}
DockerStreamFormat parses docker log messages as provided by the log-streaming API. The format is documented at https://pkg.go.dev/github.com/moby/moby/client?utm_source=godoc#Client.ContainerLogs
func NewDockerStreamFormat ¶
func NewDockerStreamFormat(containerID string) *DockerStreamFormat
NewDockerStreamFormat create a new instance of docker parser for a specific container. The given container ID is only used to generate error messages for invalid log data.
func (*DockerStreamFormat) SupportsPartialLine ¶
func (p *DockerStreamFormat) SupportsPartialLine() bool
SupportsPartialLine implements Parser#SupportsPartialLine
type EncodedText ¶
type EncodedText struct {
// contains filtered or unexported fields
}
EncodedText a parser for decoding encoded logfiles. It treats each input message as entirely content, in the given encoding. No timetamp or other metadata are returned.
func NewEncodedText ¶
func NewEncodedText(e Encoding) *EncodedText
NewEncodedText builds a new DecodingParser.
func (*EncodedText) SupportsPartialLine ¶
func (p *EncodedText) SupportsPartialLine() bool
SupportsPartialLine implements Parser#SupportsPartialLine
type Encoding ¶
type Encoding int
Encoding specifies the encoding which should be decoded by the DecodingParser
type Parser ¶
type Parser interface { // Parse parses a line of log input. It returns 1. message content, 2. // severity, 3. timestamp, 4. partial, 5. error. Parse([]byte) ([]byte, string, string, bool, error) // SupportsPartialLine returns true for sources that can have partial // lines. If SupportsPartialLine is true, Parse can return true for the // partial return value SupportsPartialLine() bool }
Parser parses messages, given as a raw byte sequence, into content and metadata.
var DockerFileFormat Parser = &dockerFileFormat{}
DockerFileFormat parses a raw JSON lines as found in docker log files, or returns an error if it failed. For example: `{"log":"a message","stream":"stderr","time":"2019-06-06T16:35:55.930852911Z"}` returns: `"a message", "error", "2019-06-06T16:35:55.930852911Z", false, nil`
var KubernetesFormat Parser = &kubernetesFormat{}
KubernetesFormat parses Kubernetes-formatted log lines. Kubernetes log lines follow the pattern '<timestamp> <stream> <flag> <content>'; see https://github.com/kubernetes/kubernetes/blob/master/pkg/kubelet/kuberuntime/logs/logs.go. For example: `2018-09-20T11:54:11.753589172Z stdout F This is my message`