Documentation
¶
Index ¶
- Variables
- func ExecuteParsers(parsers []Parser, log *types.Log, message string, name string)
- func IsValidParser(parserType string) bool
- type JsonParser
- type JsonParserConfig
- type KeyValueParser
- type KeyValueParserConfig
- type KlogParser
- type KlogParserConfig
- type Parser
- type ParserConfig
- type ParserType
- type SpaceParser
- type SpaceParserConfig
Constants ¶
This section is empty.
Variables ¶
var ( ErrNotString = errors.New("no string in log body") ErrNotJson = errors.New("no json object in log body") )
Functions ¶
func ExecuteParsers ¶
func IsValidParser ¶
Types ¶
type JsonParser ¶
type JsonParser struct {
// contains filtered or unexported fields
}
func NewJsonParser ¶
func NewJsonParser(config JsonParserConfig) (*JsonParser, error)
type JsonParserConfig ¶
type JsonParserConfig struct {
}
type KeyValueParser ¶ added in v0.2.0
type KeyValueParser struct {
// contains filtered or unexported fields
}
func NewKeyValueParser ¶ added in v0.2.0
func NewKeyValueParser(config KeyValueParserConfig) (*KeyValueParser, error)
type KeyValueParserConfig ¶ added in v0.2.0
type KeyValueParserConfig struct{}
type KlogParser ¶ added in v0.2.0
type KlogParser struct{}
func NewKlogParser ¶ added in v0.2.0
func NewKlogParser(config KlogParserConfig) (*KlogParser, error)
NewKlogParser creates a parser for the klog format. https://kubernetes.io/docs/concepts/cluster-administration/system-logs
type KlogParserConfig ¶ added in v0.2.0
type KlogParserConfig struct{}
type Parser ¶
Parser is the interface for parsing log messages.
func NewParsers ¶
NewParsers creates a list of valid parser instances. Invalid parsers or those that cannot be created will be skipped with warning logs including the source string.
type ParserConfig ¶
type ParserConfig struct {
Type ParserType
}
ParserConfig is a structure used in configs for creating parsers instances.
type ParserType ¶
type ParserType string
const ParserTypeJson ParserType = "json"
const ParserTypeKeyValue ParserType = "keyvalue"
const ParserTypeKlog ParserType = "klog"
const ParserTypeSpace ParserType = "space"
type SpaceParser ¶ added in v0.2.0
type SpaceParser struct{}
func NewSpaceParser ¶ added in v0.2.0
func NewSpaceParser(config SpaceParserConfig) (*SpaceParser, error)
func (*SpaceParser) Parse ¶ added in v0.2.0
func (p *SpaceParser) Parse(log *types.Log, msg string) error
Parse splits the message by whitespace and adds each field to the log body with a numeric index. For example, "hello world" becomes {"field0": "hello", "field1": "world"} This is useful for parsing generic log lines where fields are separated by one or more spaces. This parser uses strings.Fields, which splits on any whitespace, including tabs and newlines.
type SpaceParserConfig ¶ added in v0.2.0
type SpaceParserConfig struct{}