Splunk Search

How to deal with empty field extractions in regex

responsys_cm
Builder

Here is an example log entry I'm trying to do field extractions from:

2012 Jun 22 11:15:08 server.company.com [authpriv.notice] sshd[8410]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=host.company.com user=joe

In all of the events I've seen, the logname= and ruser= fields are always empty. But I cannot be sure that they will always be empty in future events. If I do a field extraction like the following, it never matches:

failure;\slogname\=(?P[^\s]+)\suid\=(?P\d+)

Why won't the logname=(one or more characters that aren't a space) work? And how can I work around it?

Thx.

Craig

Tags (1)
0 Karma
1 Solution

gkanapathy
Splunk Employee
Splunk Employee
failure;\slogname\=(?P<logname>\S*)\s+suid\=(?P<uid>\d+)

would be simpler.

View solution in original post

gkanapathy
Splunk Employee
Splunk Employee
failure;\slogname\=(?P<logname>\S*)\s+suid\=(?P<uid>\d+)

would be simpler.

responsys_cm
Builder

I figured it out. I have to do:

failure;\slogname\=(?P[^\s]+)?\suid\=(?P<uid.\d+)

0 Karma
Get Updates on the Splunk Community!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...