Splunk Enterprise Security

Comparing results from two searches

rupeshn
Explorer

index="A" sourcetype=B action=Yes

| search NOT [ search index="A" sourcetype=B action="No" | fields User ] | stats count by User .

Here I'm trying to get user whose action is Yes. But whenever users get 'Yes' they get 'No' as well in 20% of cases at same time.
So I want those 80% users who are having action as only Yes.

Could you please help.

1 Solution

solarboyz1
Builder

So, you looking for users who only received one of the two actions?

Using a subsearch has it's limits:
https://docs.splunk.com/Documentation/Splunk/7.3.1/SearchTutorial/Useasubsearch

You could accomplish something similar with the following:

index="A" sourcetype=B action=Yes  OR action=No
| stats dc(action) as action_count by User
| search action_count<2

View solution in original post

solarboyz1
Builder

So, you looking for users who only received one of the two actions?

Using a subsearch has it's limits:
https://docs.splunk.com/Documentation/Splunk/7.3.1/SearchTutorial/Useasubsearch

You could accomplish something similar with the following:

index="A" sourcetype=B action=Yes  OR action=No
| stats dc(action) as action_count by User
| search action_count<2

rupeshn
Explorer

@kmaron ,I've tried the query posted by you. But it still gives both the users.

0 Karma

rupeshn
Explorer

I mean users with both actions.

0 Karma

rupeshn
Explorer

Hi kmaron,

I'm getting output but i believe the output that i'm getting is very less(less number of records) than what it should be.

0 Karma

solarboyz1
Builder

If you think the results are incorrect, you can break the search down and review the data:

index="A" sourcetype=B action=Yes  OR action=No
 | stats dc(action) as action_count, values(action) as action, by User

Will show all the results, you can sort by action_count, action, etc.. Look for anomalous values for action.

0 Karma

kmaron
Motivator

please share the output you got

kmaron
Motivator

That would also give you the No people.

But changing it to

 index="A" sourcetype=B action=Yes  OR action=No
 | stats dc(action) as action_count values(action) as action by User
 | search action_count<2 AND action=Yes

Would be only Yes's.

0 Karma

solarboyz1
Builder

good catch!

0 Karma

rupeshn
Explorer

I've tried the query posted by you. But it still gives both the users.

0 Karma

rupeshn
Explorer

When i run above query I'm getting results of both users i.e., action=Yes and action= No. I'mm not sure where this Query went wrong

0 Karma

kmaron
Motivator

Are you only going to have a single Yes and/or a single No for a user? So the most entries you would have for a single user is 2?

0 Karma
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.


Introducing Unified TDIR with the New Enterprise Security 8.2

Read the blog
Get Updates on the Splunk Community!

.conf25 Community Recap

Hello Splunkers, And just like that, .conf25 is in the books! What an incredible few days — full of learning, ...

Splunk App Developers | .conf25 Recap & What’s Next

If you stopped by the Builder Bar at .conf25 this year, thank you! The retro tech beer garden vibes were ...

Congratulations to the 2025-2026 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...