Splunk Search

Extract username with dash (-) Field from event

miberecz
Loves-to-Learn

Hello Everyone,

 

I'm trying to extract usernames from the logs of a proftpd.

An event looks like this:

2021-11-16 16:17:43,866 HOST proftpd[28071] 10.10.10.10 (11.11.11.11[22.22.22.22]): USER ASD-ASDASD: Login successful.

 

Simple usernames (ASDFG) works fine, also usernames with _ like ASD_ASD. But as soon as the username contains - character, its only extract the first part ASD-ASDASD

How do I circumvent this? How can I extract strings that contains - ?

 

 

Labels (2)
0 Karma

johnhuang
Motivator

| makeresults
| eval _raw = "2021-11-16 16:17:43,866 HOST proftpd[28071] 10.10.10.10 (11.11.11.11[22.22.22.22]): USER ASD-ASDASD: Login successful."
| rex field=_raw ":\sUSER\s(?<user_id>[^:]*)"
| table user_id

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

What extraction are you currently using?

0 Karma

miberecz
Loves-to-Learn

It was extracted automatically, and so far I trusted it until I realized its not complete. Now I believe I need a regex the gets everything  after the string USER and before the : 

0 Karma

PickleRick
SplunkTrust
SplunkTrust

Extracting everything between "USER" and a colon (":") is relatively easy:

USER\s(?<username>[^:]*):

There is one caveat though. If your username contains a colon (":"), it will only capture the username up to (and without) that colon.

BTW, you could try TA for proftpd - https://github.com/jewnix/TA-proftpd

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!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...