Splunk Search

How to edit my search to filter out events where the string values between two fields are the same? (field names contain spaces)

caliburn7
Engager

Hello,

I am trying to filter out events when the source username and destination username are the same, but it is not working when I use the where and NOT field1= field2 function. Is it because I have spaces in the field names? I tried to rename them as different fields and tried the where clause, but it still didn't work. Any help is greatly appreciated.

Here is the search:

| NOT ("Source User Name"="ANONYMOUS LOGON" OR "Source User Name"=*$)  Name!="A user account was changed."   | stats dc(Name) as UniqueActionCount, values(Name) as UniqueAction by "Source User Name" | where NOT "Source User Name"="Destination User Name"

Thank you.

0 Karma
1 Solution

woodcock
Esteemed Legend

Try this:

... | search NOT ("Source User Name"="ANONYMOUS LOGON" OR "Source User Name"=*$)  Name!="A user account was changed." | stats dc(Name) as UniqueActionCount, values(Destination User Name) AS "Destination User Name" values(Name) as UniqueAction by "Source User Name" | where NOT $Source User Name$=$Destination User Name$

View solution in original post

0 Karma

woodcock
Esteemed Legend

Try this:

... | search NOT ("Source User Name"="ANONYMOUS LOGON" OR "Source User Name"=*$)  Name!="A user account was changed." | stats dc(Name) as UniqueActionCount, values(Destination User Name) AS "Destination User Name" values(Name) as UniqueAction by "Source User Name" | where NOT $Source User Name$=$Destination User Name$
0 Karma

caliburn7
Engager

Thank you, this helped!

0 Karma

sundareshr
Legend

Try putting single quotes around your fields. Like below. But what is *$"?

| where NOT ('Source User Name'='ANONYMOUS LOGON' OR 'Source User Name'="*$") AND Name!="A user account was changed."   | stats dc(Name) as UniqueActionCount, values(Name) as UniqueAction by "Source User Name" | where NOT 'Source User Name'='Destination User Name'
0 Karma

caliburn7
Engager

username=*$ was to filter all usernames that end with $, which are system authentications, and when not an actual user is present.

0 Karma

somesoni2
Revered Legend

Issue 1: After your stats there is no field called "Destination User Name", so even if the where syntax was correct, it will not give you any result
Issue 2. In where clause, fields names should be enclosed in single quotes if they contain spaces/dots etc.

caliburn7
Engager

Thank you, this helped 🙂

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!

What Is Splunk? Here’s What You Can Do with Splunk

Hey Splunk Community, we know you know Splunk. You likely leverage its unparalleled ability to ingest, index, ...

Level Up Your .conf25: Splunk Arcade Comes to Boston

With .conf25 right around the corner in Boston, there’s a lot to look forward to — inspiring keynotes, ...

Manual Instrumentation with Splunk Observability Cloud: How to Instrument Frontend ...

Although it might seem daunting, as we’ve seen in this series, manual instrumentation can be straightforward ...