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!

Introducing the 2024 SplunkTrust!

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

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...