Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct {
File string
MaxRecSizeBytes int
DataFmt DataFormat
DateFmts []string
}
type DataFormat ¶
type DataFormat string
const ( FmtText DataFormat = "text" FmtK8Json DataFormat = "k8json" )
type K8sJsonLogParser ¶
type K8sJsonLogParser struct {
// contains filtered or unexported fields
}
K8sJsonLogParser implements parser.Parser, for reading lines(strings with \n separation) from a text file, treating every line as a k8s json log message (fixed fields). The parser doesn't pay much attention to parsing dates, as they are presented as time.Time object in case of k8s log and in such a case JSON deserialization should take care of it. Additionally to message and date the parser also saves some additional metadata like 'pipe' (stdout/strerr), which is provided in k8s logs, the result of parsing is model.Record.
func NewK8sJsonParser ¶
func NewK8sJsonParser(fileName string, maxRecSize int) (*K8sJsonLogParser, error)
func (*K8sJsonLogParser) Close ¶
func (jp *K8sJsonLogParser) Close() error
func (*K8sJsonLogParser) GetStats ¶
func (jp *K8sJsonLogParser) GetStats() *Stats
func (*K8sJsonLogParser) GetStreamPos ¶
func (jp *K8sJsonLogParser) GetStreamPos() int64
func (*K8sJsonLogParser) NextRecord ¶
func (*K8sJsonLogParser) SetStreamPos ¶
func (jp *K8sJsonLogParser) SetStreamPos(pos int64) error
type K8sJsonLogRec ¶
type K8sJsonLogRec struct {
Log string `json:"log"`
Stream string `json:"stream"`
Time time.Time `json:"time"`
}
K8sJsonLogRec defines format of k8s json log line
type Parser ¶
type Parser interface {
io.Closer
// NextRecord parses next record. It returns error if it could not parse
// a record from the pipe. io.EOF is returned if no new records found, but
// end is reached.
NextRecord(ctx context.Context) (*model.Record, error)
// SetStreamPos specifies the pipe position for the next record read
SetStreamPos(pos int64) error
// GetStreamPos returns position of the last successfully (error was nil)
// returned record by nextRecord(). If nextRecord() returned non-nil
// error the getStreamPos() returned value is not relevant and should
// not be used as a valid pipe position.
GetStreamPos() int64
// GetStat returns the parser statistic
GetStats() *Stats
}
Parser provides an interface for retrieving records from a data-pipe. Implementations of the interface are supposed to be initialized by the pipe (io.Reader)
type Stats ¶
type Stats struct {
DataFormat DataFormat
FileStats *fileStats
FmtStats *fmtStats // for text parsers only...
}
Stats struct contains information about the parser statistics
func NewJsonStats ¶
func NewJsonStats() *Stats
func NewTxtStats ¶
func NewTxtStats() *Stats