Splunk Search

How to compare values of a field if they are same and save the match or non-match result in different field.

arrangineni
Path Finder

I am trying to compare the values of a field IP and trigger the alert if the values are different based on the UserName field and Sesson Id.

My search looks like the below
index=758.......
| stats count(user) as count , list(name) as UserName , list(IP) as IP by SessionId | where count>1
| eval Match=if(IP=IP, "Match", "No Match")
| table ASP_NET_SessionId UserName IP Match

Can someone help me with the changes to this query so that I can know which User is using which IP's and trigger an alert if they are using different set of IP's?

Tags (2)
0 Karma

renjith_nair
Legend

@arrangineni,

If you are looking for a user who uses multiple IPs to login , try this

index="your index"|stats values(IP) as IPList,values(SessionId) as SessionId  by user | where mvcount(IPList) > 1

If you want to check for multiple IPs for same session id which is possible (proxy,ISP routing,etc), add SessionId also to the by clause

---
What goes around comes around. If it helps, hit it with Karma 🙂
0 Karma

arrangineni
Path Finder

I am trying to find out a scenario where two different users use same session ID from different IP's ..

Currently my results looks like this
SessionID Username IP
abc... xyz 12.34.65.68
abc... uyw 64.5.565.75

So in the above scenario both users use same IP's with different names using same session ID, I want the alert when the two users use different IP's using same session ID, Can you help with this?

0 Karma

renjith_nair
Legend

@arrangineni,

index="your index"|stats dc(IP) as ipcount,values(name) as UserName by SessionId
  |where ipcount > 1

Above should result if one session id has more than one distinct IP.

---
What goes around comes around. If it helps, hit it with Karma 🙂
0 Karma
Get Updates on the Splunk Community!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...