Splunk Search

How do I extract the status from authentication logs into an action field?

ysifusuf
Engager

Hello!
Please let me know how can I extract the status of the authentication from the following logs into an action field.

CRON: pam_unix(cron:session): session opened for user root by (uid=0)
CRON: pam_unix(cron:session): session closed for user root

thanks!

0 Karma
1 Solution

DavidHourani
Super Champion

Hi @ysifusuf,

You can get that extracted directly within your search as follows :

..... | rex field=_raw "([^:]+\:)+\ssession\s(?<action>\w+)\s"

Or if you add it as an extracted field to have it automatically on your next search as shown here for GUI:
https://docs.splunk.com/Documentation/Splunk/7.2.6/Knowledge/Managesearch-timefieldextractions#Revie...
Or by editing props.conf :

[your_authentication_sourcetype]
EXTRACT-action = ([^:]+\:)+\ssession\s(?<action>\w+)\s

Cheers,
David

View solution in original post

preactivity
Path Finder

You can also do like this,

| rex field=_raw "^(?:[^ \n]* ){3}(?P\w+)"

0 Karma

DavidHourani
Super Champion

Hi @ysifusuf,

You can get that extracted directly within your search as follows :

..... | rex field=_raw "([^:]+\:)+\ssession\s(?<action>\w+)\s"

Or if you add it as an extracted field to have it automatically on your next search as shown here for GUI:
https://docs.splunk.com/Documentation/Splunk/7.2.6/Knowledge/Managesearch-timefieldextractions#Revie...
Or by editing props.conf :

[your_authentication_sourcetype]
EXTRACT-action = ([^:]+\:)+\ssession\s(?<action>\w+)\s

Cheers,
David

ysifusuf
Engager

Hey man,
it works, thanks
@DavidHourani

0 Karma

DavidHourani
Super Champion

you're welcome !

0 Karma

richgalloway
SplunkTrust
SplunkTrust

There are a number of ways to do that, depending on your specific needs. Here's one:

 index=foo | rex "session (?<action>\S+) for user (?<user>\S+)" | ...
---
If this reply helps you, Karma would be appreciated.
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!

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...

Modernize your Splunk Apps – Introducing Python 3.13 in Splunk

We are excited to announce that the upcoming releases of Splunk Enterprise 10.2.x and Splunk Cloud Platform ...

Step into “Hunt the Insider: An Splunk ES Premier Mystery” to catch a cybercriminal ...

After a whole week of being on call, you fell asleep on your keyboard, and you hit a sequence of buttons that ...