graylog2-server icon indicating copy to clipboard operation
graylog2-server copied to clipboard

Grok support for extractors

Open henrikjohansen opened this issue 12 years ago • 13 comments

When it comes to parsing complex (read:crappy) log formats Jordan Sissel hit a homerun with the concepts and ideas behind Grok.

I have tried plain regex'es and drools but neither can match the ease, speed, and maintainability of grok patterns.

As a bonus it would enable a lot of transparency between Logstash and Graylog2.

Parsing crappy syslog like this :

srvesbmanxxxx api-log: 2014-01-15 14:46:33,382 INFO [cloud.api.ApiServer] (catalina-exec-13:null) (userId=x accountId=x sessionId=3A0E966E2xxxxxx) 10.x.x.x -- GET command=queryAsyncJobResult&jobId=b74d9ce1-0423-4a3e-b460-217787cf0681&response=json&sessionkey=0WfyV4trvb5ng6XrRLCAxHx3KOA%3D&_=1389793597907 200 { "queryasyncjobresultresponse" : {"accountid":"xxxxx-xxxx-11e3-bbe0-235130fb5cd9","userid":"xxxxx-60d0-xxxx-bbe0-235130fb5cd9","cmd":"org.apache.cloudstack.api.command.admin.storage.PreparePrimaryStorageForMaintenanceCmd","jobstatus":1,"jobprocstatus":0,"jobresultcode":0,"jobresulttype":"object","jobresult":{"storagepool":{"id":"xxxxxx-f3ca-3ed7-9ae2-6d79a56d3e90","zoneid":"xxxxxx-99cc-4ab6-a009-04a15d3ccd0a","zonename":"DCE-POC1","podid":"xxxxxxx-b4f7-4994-bd2f-9391e8fbd6d5","podname":"RACK5-DCE_POC1","name":"PR_NP0","ipaddress":"xxx.xxx.xxx.xxx","path":"/ds0002_nfs_fc","created":"2014-01-15T14:46:19+0100","type":"NetworkFilesystem","clusterid":"xxxxx-b113-4dbc-8301-1fd8ce1f5a60","clustername":"xxx.xxx.3.250/DCE_Zone_1/DCE_POC1","disksizetotal":1099511627776,"disksizeallocated":0,"tags":"PR_NP_0","state":"Maintenance","scope":"CLUSTER","jobid":"xxxxx-0423-4a3e-b460-217787cf0681","jobstatus":0}},"created":"2014-01-15T14:46:30+0100","jobid":"xxxx-0423-4a3e-b460-217787cf0681"} }

took 2 minutes using something like this :

%{HOSTNAME:host} %{NOTSPACE:log-type} %{NOTSPACE:date} %{NOTSPACE:time} %{WORD:level} %{NOTSPACE:path} %{NOTSPACE:thread} %{NOTSPACE:userid} %{NOTSPACE:accountid} %{NOTSPACE:sessionid} %{IP:ip} -- %{WORD:method} %{NOTSPACE:command} %{INT:status_code} %{GREEDYDATA:request}

henrikjohansen avatar Jan 16 '14 18:01 henrikjohansen

:+1:

hggh avatar Feb 06 '14 21:02 hggh

+1

bonJoeV avatar Feb 09 '14 21:02 bonJoeV

+1

ghost avatar Feb 17 '14 11:02 ghost

+∞

jpmens avatar Apr 15 '14 08:04 jpmens

+1

sebclick avatar May 13 '14 16:05 sebclick

Grok conversion (int and float) could be also implemented. E.g. %{NUMBER:num:int} or %{NUMBER:amount:float}

timukas avatar May 18 '14 10:05 timukas

+1

r-duran avatar Nov 20 '14 06:11 r-duran

https://github.com/Graylog2/graylog2-server/commit/de30ca6934d6a2d3a90219b3d66bd2e8fdcc16c2

kroepke avatar Jan 08 '15 15:01 kroepke

Can you add default's patterns (as logstash do : https://github.com/elasticsearch/logstash/tree/v1.4.0/patterns) ?

sebclick avatar Jan 12 '15 20:01 sebclick

@sebclick we will likely not ship with default patters, but you can now import pattern files with two clicks.

that will be available in beta.2

kroepke avatar Jan 14 '15 21:01 kroepke

@kroepke Nice :smile:

sebclick avatar Jan 15 '15 07:01 sebclick

has been implemented in way too many commits.

kroepke avatar Jan 20 '15 10:01 kroepke

Brilliant feature, thank you!

razvanphp avatar Feb 26 '15 12:02 razvanphp