Skip to content

vjeantet/groker

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

groker

Simple library to parse grok patterns with go.

This small tool reads from standard input, applies a grok pattern and dumps the captured fields as JSON.

Examples

cat apache.log | groker -pattern=%{COMMONAPACHELOG}
echo "Hello 123" | groker -pattern="%{WORD:word} %{WORD:number}"
// output: {"number":"123","word":"Hello"}
echo "2015-06-16T01:47:07.665Z" | ./groker -pattern="%{TIMESTAMP_ISO8601:time}"
{"HOUR":"","ISO8601_TIMEZONE":"Z","MINUTE":"","MONTHDAY":"16","MONTHNUM":"06","SECOND":"07.665","YEAR":"2015","time":"2015-06-16T01:47:07.665Z"}
echo "2015-06-16T01:47:07.665Z" | ./groker -pattern="%{TIMESTAMP_ISO8601:time}" -namedcapture
// output: {"time":"2015-06-16T01:47:07.665Z"}

Installation

It is based on gemsi/grok.

go get github.com/gemsi/grok
go build

TODO

  • Support more output formats.
  • Differentiate numbers, booleans and strings.

About

simple library to parse grok patterns with go

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%