Splunk Search

List of event codes that found in another search

dyeo
Engager

Hi, I'm trying to create a query to provide a list of event codes that are found in one period time that is NOT found in another time period. This is what I came up with, but it looks like it's just giving me the aggregate results from both searches.

index=win* EventCode=* earliest=-2d@d latest=now NOT [search index=win* EventCode=* earliest=-60d@d latest=-58d@d | stats count by EventCode] | stats count by EventCode
Tags (2)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

Your query is close. Try this one:

index=win* EventCode= earliest=-2d@d latest=now NOT 
    [search index=win EventCode=* earliest=-60d@d latest=-58d@d 
    | stats count by EventCode | fields EventCode | format ] 
| stats count by EventCode

The key is the subsearch. In it's original form, it was passing counts and EventCode values to the main search. That's why your results looked the way they did. The new form will pass only EventCode values to the main search.

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

View solution in original post

0 Karma

richgalloway
SplunkTrust
SplunkTrust

Your query is close. Try this one:

index=win* EventCode= earliest=-2d@d latest=now NOT 
    [search index=win EventCode=* earliest=-60d@d latest=-58d@d 
    | stats count by EventCode | fields EventCode | format ] 
| stats count by EventCode

The key is the subsearch. In it's original form, it was passing counts and EventCode values to the main search. That's why your results looked the way they did. The new form will pass only EventCode values to the main search.

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

dyeo
Engager

Thanks Rich! That seems to have done it!

0 Karma
Get Updates on the Splunk Community!

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...

.conf24 | Personalize your .conf experience with Learning Paths!

Personalize your .conf24 Experience Learning paths allow you to level up your skill sets and dive deeper ...

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...