Splunk Search

Regex to find Account_Name's that end in a $ and \ isn't stopping it's special char nature

benbabich
Explorer

I want to find all names in Account_Name that end with a $ and not ones that don't. IE: I want NAME1$ but not NAME2.
I've been trying regex Account_Name=".*\$" but am still getting NAME2.
Any ideas?

Tags (2)
0 Karma

agarrison
Path Finder

You could try something like this Account_Name=\w+\$ to match account names that are letters, or something like Account_Name=.+\$ if your accounts have other characters.

For reference here is a transform I have that finds account names that match the computer name with a $ at the end and drop those events, I usually don't care about all the spam events from local accounts on the computer itself.

[ignorelocalaccount]
REGEX=(?msi)EventCode=(?:4624|4634).+^ComputerName=(\w+).+\s+Account\sName:\s+(\1\$)
DEST_KEY=queue
FORMAT=nullQueue

0 Karma

richgalloway
SplunkTrust
SplunkTrust

Does the answer have to be regex? Have you tried ... | where Account_Name="*$" | ... ?

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

benbabich
Explorer

I really wanted that to work. But where ".\$" in Regex still gives me names not ending in $, | where Account_Name="$" | gives me zero results.
I'll play around with it and see though.

0 Karma

nickhills
Ultra Champion
... user="*$"|table user

Works for me, but perhaps I have misunderstood exactly what you are asking!

...|rex field=user "(?<userDollar>.+\$)"|table user userDollar

also works, and creates a new field which will only include usernames ending with $

If my comment helps, please give it a thumbs up!
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!

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...

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 ...