Splunk Search

Regex SOS!

sdorich
Communicator

I'm trying to match everything in quotes in the following log file example. I've been working on this for a while and am desperate!

This regex matches the first item in quotes in a given event (but I want to match everything).

((?:[^ \n]* ){1,8}'(?P<sis_audit_type>[^']+))

I would have thought that this regex works but it gives an error:

([^]+:[^]+:\s[^]+'(?P<sis_audit_type>[^]+)'){1,5}

My example log file is attached and pasted below. Thanks!alt text

2014-02-03 05:26:53 - User: SiteScope Administrator. Operation performed: logged in.
2014-02-03 10:19:20 - User: SiteScope Administrator. Operation performed: Username and password do not match. Failed to login.
2014-02-03 10:19:24 - User: SiteScope Administrator. Operation performed: logged in.
2014-02-03 11:44:33 - User: SiteScope Administrator. Operation performed: logged in.
2014-02-03 11:53:54 - User: SiteScope Administrator. Operation performed: logged in.
2014-02-03 12:10:17 - User: SiteScope Administrator. Operation performed: Alert 'sound' created in 'SiteScope\Test\google.com'.
2014-02-03 12:10:43 - User: SiteScope Administrator. Operation performed: UPDATE Monitor 'SiteScope\Test\google.com' start:
2014-02-03 12:10:43 - User: SiteScope Administrator. Operation performed: Monitor 'SiteScope\Test\google.com' update: '_classifier2' updated from '' to 'percentGood != 0 error every day, all day'.
2014-02-03 12:10:43 - User: SiteScope Administrator. Operation performed: Monitor 'SiteScope\Test\google.com' update: '_classifier1' updated from 'percentGood == 0 error every day, all day' to ''.
2014-02-03 12:10:43 - User: SiteScope Administrator. Operation performed: UPDATE Monitor 'SiteScope\Test\google.com' end.
2014-02-03 12:10:43 - User: SiteScope Administrator. Operation performed: MANUAL RUN for monitor 'SiteScope\Test\google.com'.
2014-02-03 12:20:18 - User: SiteScope Administrator. Operation performed: MODIFY Acknowledgment on 'SiteScope\Test\google.com' start:
2014-02-03 12:20:18 - User: SiteScope Administrator. Operation performed: Acknowledgment 'ack google' was added to 'SiteScope\Test\google.com'
2014-02-03 12:20:18 - User: SiteScope Administrator. Operation performed: UPDATE Monitor 'SiteScope\Test\google.com' start:
2014-02-03 12:20:18 - User: SiteScope Administrator. Operation performed: UPDATE Monitor 'SiteScope\Test\google.com' end.
2014-02-03 12:20:18 - User: SiteScope Administrator. Operation performed: MODIFY Acknowledgment on 'SiteScope\Test\google.com' end.
2014-02-03 13:22:42 - User: SiteScope Administrator. Operation performed: logged in.
2014-02-03 13:28:00 - User: SiteScope Administrator. Operation performed: logged out.
2014-02-03 13:28:10 - User: . Operation performed: Username and password do not match. Failed to login.

Tags (1)
0 Karma
1 Solution

somesoni2
Revered Legend

Try this one.

yourbase search | rex max_match=0 "'(?<sis_audit_type>[^']*)'\s"

View solution in original post

somesoni2
Revered Legend

Try this one.

yourbase search | rex max_match=0 "'(?<sis_audit_type>[^']*)'\s"

sdorich
Communicator

Thank you! I think that worked pretty well! One question: how can I use that as a regular expression in say props.conf? I tried this:

EXTRACT-Audit Type = '(?[^']*)'\s

but that didn't work.. It seems to only work with the rex search command. Is there something I need to modify to use it in props.conf?

Thanks!

0 Karma

sdorich
Communicator

Thanks! I tried it and was close but I got everything in b/w the values with quotes. For example, I got this:

ack google' was added to 'SiteScopeTestgoogle.com'

but what I'd really like are the following 2 separate values:

ack google
SSiteScopeTestgoogle.com

0 Karma

somesoni2
Revered Legend

try this

yourbase search | rex max_match=0 "'(?.*)'" | nomv sis_audit_type

To see if you get correct values.

0 Karma

sdorich
Communicator

yes. I'd like (if possible) all the values in quotes as a single field.

0 Karma

somesoni2
Revered Legend

You want to get all the values in quotes as a single field?

0 Karma

sdorich
Communicator

Just added the sample events (each timestamp represents a new event). Thanks!

0 Karma

Ayn
Legend

It'd be much easier to debug this if you could post sample events as text instead. That way it's easy to try to create a matching regex on http://regexpal.com/ or something similar.

0 Karma
Get Updates on the Splunk Community!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...