Splunk Search

How do I construct a regular expression with wildcard matching?

dbcase
Motivator

Hi,

I have data that looks like this

####<Sep 15, 2016 9:35:27 AM CDT> <Debug> <ucontrol> <betamax-cpe1> <managedServer1> <client-8> <<anonymous>> <> <> <1473950127749> <BEA-000000> <org.jivesoftware.util.Log  - SENT: <failure xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><not-authorized/></failure>> 

####<Sep 15, 2016 10:18:53 AM CDT> <Warning> <ucontrol> <betamax-cpe1> <managedServer1> <smsQueueListenerContainer-1> <<anonymous>> <BEA1-35C7B98CDE9F> <> <1473952733478> <BEA-000000> <fn.service.impl.NumerexSmsSender  - UCE-22233 - Failed to send Numerex sms message to 5555555555> 

####<Sep 15, 2016 10:11:46 AM CDT> <Warning> <ucontrol> <betamax-portal1> <managedServer3> <[ACTIVE] ExecuteThread: '7' for queue: 'weblogic.kernel.Default (self-tuning)'> <<anonymous>> <> <> <1473952306182> <BEA-000000> <fn.webapp.listener.AuthenticationListener  - Authentication Auditing Failed: AuthenticationFailureBadCredentialsEvent> 

What I need to do is search on a failure but the failure condition is presented in several ways (i.e. failed: OR failed; OR failed, OR failed. OR <failure

What I need to do is match on failed* OR <failure and then capture to the end of the line.

Still rather new to regex so I'm unsure how to do wildcard matching

0 Karma
1 Solution

sundareshr
Legend

Try this

... | rex "\b(?<failmsg>[Ff]ail.*)"

View solution in original post

aaraneta_splunk
Splunk Employee
Splunk Employee

Hi @dbcase - Just so you know, I edited your original question to include your revised/correct last sentence instead of having it as a floating comment 🙂

0 Karma

sundareshr
Legend

Try this

... | rex "\b(?<failmsg>[Ff]ail.*)"

dbcase
Motivator

I have no idea how you do regex so eloquently.... Maybe one day I can do the same.... 🙂

0 Karma

twinspop
Influencer
... | rex "<?[fF]ail[eu][dr]?e?[:;,. ](?<failure_code>.*)"
0 Karma

richgalloway
SplunkTrust
SplunkTrust

Something like this, perhaps?

... | rex "fail\w*\s*(?<failureMsg>.*)" | ...
---
If this reply helps you, Karma would be appreciated.
0 Karma

inventsekar
SplunkTrust
SplunkTrust

Please check this -

sourcetype=failure | rex field=_raw "<?[fF]ail[eu][dr]?e?[:;,. ](?<failedCode>.*)" | table failedCode _time _raw
0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Free Professional Services for .conf26 Attendees

This year at .conf26, we are doing something a little different. We are bringing the best minds from ...

Defend at Machine Speed: Your Guide to Security Sessions at .conf26

Splunk .conf26   With threats moving at machine speed and attack surfaces expanding across hybrid ...

Where Innovation Takes Flight: The Splunk4Aviation Flight Sim Lands at .conf26

If you hear someone at .conf26 shouting "gear down, GEAR DOWN" across the show floor, you have found us.  The ...