How to put regex group to field with grok

This support forum board is for support questions relating to Nagios Log Server, our solution for managing and monitoring critical log data.
Locked
_asp_
Posts: 91
Joined: Mon May 23, 2016 4:30 am

How to put regex group to field with grok

Post by _asp_ »

Hi,

we are currently evaluating nagios logserver.
Via nxlog we are moving logfiles in json codec to logstash.

log lines may be the following example:

Code: Select all

001020.service1.5563:WARN: This is a warning message
001023.service2.5643.24.-5:ERROR: This is an error message
thats the logical format:
time.serviceName.someNumbers:logLevel: logmessage

I would use following regex to extract my needed values:

Code: Select all

^\d{6}.([^\.]+)[^\:]+:(INFO|WARN|ERROR):(.*)
result of first line:
$1=service1
$2=WARN
$3= This is a warning message

I am so far that I can put $1 and $3 into fields, with grok:

Code: Select all

^\d{6}.(%{WORD:service})[^\:]+:(INFO|WARN|ERROR):%{GREEDYDATA:message}
but I do not know how to process $2.

Hopefully you can help me.
Regards, Andreas

PS: The timestamp here is not important for me, because we only have the time but no date here. The complete timestamp (date + time) will be combined by nxlog.
User avatar
hsmith
Agent Smith
Posts: 3539
Joined: Thu Jul 30, 2015 11:09 am
Location: 127.0.0.1
Contact:

Re: How to put regex group to field with grok

Post by hsmith »

Are they coming in to the server as multiple messages?
Former Nagios Employee.
me.
Locked