Splunk Search

Splunk more than one mvcount or if statement in mvcount

Pmeiring
Explorer

Hi Community, 

I'm trying to optimize an existing query to only return values only if a condition is met. 

The existing query:
source="/var/log/wireless.log" AnyConnect OR NetworkDeviceName=fw* "NOTICE Passed-Authentication: Authentication succeeded"
| stats values(Calling_Station_ID) as Public_IP by UserName
| where mvcount(Public_IP) > 1

The output looks something like this: 

UsernamePublic IP
test6849@domain.com127.229.3.176
127.89.234.34
Example678127.122.158.253
127.122.181.170
example5645@domain.com127.96.171.82
127.13.146.208
Example123127.114.242.14
127.114.243.135
127.114.252.31
test123@domain.com127.157.205.179
127.157.211.18
Example586127.94.41.110
127.114.213.249

 

What I'm trying to achieve is only to have this return IF the Public IP address subnets differ. 

As an example values I want returned: 

test6849@domain.comxx.229.3.176
xy.89.234.34


AND not these values - Notice the first 2 subnets are the same (underlined)

UsernamePublic IP
Example678xyz.122.158.253
xyz.122.181.170
Example123127.114.242.14
127.114.243.135
127.114.252.31


I managed to identify the first 2 subnets with regex - but I'm unable to get my query to return values. 

source="/var/log/wireless.log" AnyConnect OR NetworkDeviceName=fw* "NOTICE Passed-Authentication: Authentication succeeded"
| stats values(Calling_Station_ID) as Public_IP by UserName
| stats values(Public_IP_octet) as Subnet_count by UserName
| where (mvcount(Public_IP) > 1 AND mvcount(Subnet_count) < 2)

Any help would be appreciated 

Labels (2)
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust
source="/var/log/wireless.log" AnyConnect OR NetworkDeviceName=fw* "NOTICE Passed-Authentication: Authentication succeeded"
| rex field=Calling_Station_ID "(?<subnet>\d+\.\d+)"
| stats values(Calling_Station_ID) as Public_IP values(subnet) as Subnets by UserName
| where mvcount(Subnets) > 1

View solution in original post

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
source="/var/log/wireless.log" AnyConnect OR NetworkDeviceName=fw* "NOTICE Passed-Authentication: Authentication succeeded"
| rex field=Calling_Station_ID "(?<subnet>\d+\.\d+)"
| stats values(Calling_Station_ID) as Public_IP values(subnet) as Subnets by UserName
| where mvcount(Subnets) > 1
0 Karma

Pmeiring
Explorer

Thanks @ITWhisperer  works perfectly 

0 Karma
Get Updates on the Splunk Community!

Splunk Mobile: Your Brand-New Home Screen

Meet Your New Mobile Hub  Hello Splunk Community!  Staying connected to your data—no matter where you are—is ...

Introducing Value Insights (Beta): Understand the Business Impact your organization ...

Real progress on your strategic priorities starts with knowing the business outcomes your teams are delivering ...

Enterprise Security (ES) Essentials 8.3 is Now GA — Smarter Detections, Faster ...

As of today, Enterprise Security (ES) Essentials 8.3 is now generally available, helping SOC teams simplify ...