Splunk Search

rex not working for log4j

pcorchary
Explorer

trying to extract COMPANY from each matched log line, given tomcat log4j lines like this:

31 Jan 2012 23:59:39,963 [com.action.ProcessPassword] (TP-Processor87) (8e48955b5d66036:24.6.170.156) DEBUG: Started executeExternalProcessPassword() for name @ COMPANY

why doesn't this rex work? (no results)

index="myIndex" rex field=_raw "executeExternalProcessPassword.* @ (?<org>.*)"

just index="myIndex" "executeExternalProcessPassword" returns 22k+ lines from just one day log span

this works perfectly:

perl -ne 'if (/executeExternalProcessPassword.*@(.+)$/) {print "$1\n"}' catalina.out
Tags (2)
0 Karma

lguinn2
Legend

The spacing appears different in the different regexes that you are showing. Maybe it's just the linebreaking or the font of your post, though. Try

index=myIndex | rex "executeExternalProcessPassword.*@(?<org>.+)$"

dwaddle
SplunkTrust
SplunkTrust

We were discussing this in #splunk IRC, and the missing pipe character before rex in the question/example turned out to be the real culprit.

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Level Up Your .conf25: Splunk Arcade Comes to Boston

With .conf25 right around the corner in Boston, there’s a lot to look forward to — inspiring keynotes, ...

Manual Instrumentation with Splunk Observability Cloud: How to Instrument Frontend ...

Although it might seem daunting, as we’ve seen in this series, manual instrumentation can be straightforward ...

Take Action Automatically on Splunk Alerts with Red Hat Ansible Automation Platform

 Are you ready to revolutionize your IT operations? As digital transformation accelerates, the demand for ...