Security
Provide Splunk Cloud feedback in this confidential UX survey by June 17
for a chance to win a $200 Amazon gift card!

Get the list of Users from the below message in a Log file

webnair
Explorer

In the below log file: the users are JACK, ROGER

I used something like this: source="/var/log/splunk/splunkcloud/" message=*User

I need to just get the User from the below message string.

{[-]
app : "test_res",
level : 1,
message : "User JACK logged into Serv from IP address: x.xx.xxx.xx",
time : "2014-04-16T17:28:26+00:00"
}
Show as raw text
date_hour=17 Options| date_mday=16 Options| date_minute=23 Options| date_month=april Options| date_second=2 Options| date_wday=wednesday Options| date_year=2014 Options| date_zone=local Options| host=splunk Options| index=main Options| linecount=1 Options| punct={"":"","":"____:...","":,"":"--::+:"} Options| source=/var/log/splunk/splunkcloud.log Options| sourcetype=access_combined Options| splunk_server=splunk Options
2 » 4/16/14
5:23:02.000 PM

{[-]
app : "test_res",
level : 1,
message : "User ROGER logged into ownCloud from IP address: xx.xx.xxx.xx",
time : "2014-04-16T17:28:25+00:00"
}
Show as raw text
date_hour=17 Options| date_mday=16 Options| date_minute=23 Options| date_month=april Options| date_second=2 Options| date_wday=wednesday Options| date_year=2014 Options| date_zone=local Options| host=splunk Options| index=main Options| linecount=1 Options| punct={"":"","":"
____:...","":,"":"--::+:"} Options| source=/var/log/splunk/splunkcloud.log Options| sourcetype=access_combined Options| splunk_server=ala-splunk

Tags (3)
0 Karma

lguinn2
Legend

This should work

source="/var/log/splunk/splunkcloud/" message=User*
| rex "message.*?User\s(?<User>\S+)"

This should give you the a field named User.

0 Karma

martin_mueller
SplunkTrust
SplunkTrust

You could for example append a call to top:

source="/var/log/splunk/splunkcloud/" message=User* | rex "message.*?User\s(?<User>\S+)" | top User
0 Karma

webnair
Explorer

Thanks lguinn for the quick response. However, I do not get the list of Users. I'm looking to get just the User (JACK, ROGER) from the above log to be displayed.
The source is ="/var/log/splunk/splunkcloud/*"It will be very valuable if you can let me know how to get just the username from the message string from the above log

0 Karma
Take the 2021 Splunk Career Survey

Help us learn about how Splunk has
impacted your career by taking the 2021 Splunk Career Survey.

Earn $50 in Amazon cash!