Splunk Search

_audit search for regex's

reneedeleon
Engager

Is it possible to build a search looking for regex variances? i.e. SSN regex, CC regex

Tags (2)
0 Karma

woodcock
Esteemed Legend

Try this:

index=_audit sourcetype=audittrail action=search
| regex search="(?<!\d)(\d{3}[\s\-]\d{2}[\s\-]\d{4})|(\d{4}[\s\-]\d{4}[\s\-]\d{4}[\s\-]\d{4})(?!\d)"
0 Karma

ryhluc01
Communicator

What are you asking? What should your query or data should look like.
Are you trying to locate those patterns (regex or rex)? Replace things (rex)? What do you mean when you say regex variance? Are you trying to test your pattern to see if it will work on your data?

Just in case:
SSN regex:

\d{3}-\d{2}-\d{4}

Testing sites I use:
https://regex101.com/
https://regexr.com/3f4vo (Engine needs to be changed to PCRE)

I need more information before I can help you with your query.

0 Karma

reneedeleon
Engager

I am looking for both regex and rex. I have the same SSN regex. (I am not really good with generating rex or regex) We want to monitor our _audit index for searches containing SSN, specific IP addresses and Credit Card rex and/or regex's. As far as variances I was meaning rex and regex.

0 Karma

richgalloway
SplunkTrust
SplunkTrust

So you want to know whenever one of your users searches for a SSN, IP address, or credit card number, is that it? If so, you have quite a challenge on your hands. There are a great many ways to construct regular expressions for each of those and a regular expression to detect those regular expressions is beyond anything I'd like to try.
Of course, if your data doesn't contain any SSNs or CC numbers (and it really should not) then it doesn't matter if anyone searches for them.
Perhaps if you described the problem you're trying to solve we can offer another solution.

---
If this reply helps you, Karma would be appreciated.
0 Karma

reneedeleon
Engager

That is exactly as you stated. We are sure our data does not contain CC and SSN but you never know. But I do know we have IP addresses in our data. Since this is a completely new realm to me I am trying to gather as much information as possible to attempt a query searching for regex's such as SSN, CC and IP addresses, but of course it would help if I can explain my questions better as well.

0 Karma

richgalloway
SplunkTrust
SplunkTrust

Please explain your use case. What is a "regex variance"?

---
If this reply helps you, Karma would be appreciated.
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!

Index This | What travels the world but is also stuck in place?

April 2026 Edition  Hayyy Splunk Education Enthusiasts and the Eternally Curious!   We’re back with this ...

Discover New Use Cases: Unlock Greater Value from Your Existing Splunk Data

Realizing the full potential of your Splunk investment requires more than just understanding current usage; it ...

Continue Your Journey: Join Session 2 of the Data Management and Federation Bootcamp ...

As data volumes continue to grow and environments become more distributed, managing and optimizing data ...