Knowledge Management

How do you search for event types that return no results?

JordanPeterson
Path Finder

I have a list of event types I'm searching for based on a standard naming convention. I want to be able to return a list of event types that have not occurred in the given time frame. Right now, my search looks something like this:

eventtype=ps-*

And then from there, I am working with the list of returned events. I need a separate search to get a list of the event types that didn't return anything.

Thoughts?

0 Karma
1 Solution

DalJeanis
Legend

Try something like....

  eventtype=ps-* 
  | fields eventtype
  | dedup eventtype 
  | eval status="foundme" 
  | append [ 
     | rest servicesNS/-/-/saved/eventtypes
     | table title
     | eval status="notfound" ]
  | dedup eventtype
  | where eventtype="notfound"

View solution in original post

DalJeanis
Legend

Try something like....

  eventtype=ps-* 
  | fields eventtype
  | dedup eventtype 
  | eval status="foundme" 
  | append [ 
     | rest servicesNS/-/-/saved/eventtypes
     | table title
     | eval status="notfound" ]
  | dedup eventtype
  | where eventtype="notfound"

JordanPeterson
Path Finder

This is very close to what I needed. Yours had a few syntax differences from what I needed but I used it as the baseline for this:

eventtype=PS-* 
| dedup eventtype 
| eval found="TRUE" 
| table eventtype found 
| append 
    [| rest servicesNS/-/-/saved/eventtypes 
    | search title=PS-* 
    | eval found="FALSE" 
    | rename title AS eventtype 
    | table eventtype found] 
| sort -found 
| dedup eventtype 
| where found="FALSE"
| table eventtype
0 Karma

DalJeanis
Legend

Since the FALSE values in the append come after the TRUE values, the sort is unnecessary work for the CPU, but that's a nit. Glad it worked for you.

By the way, change your sort to this...

| sort 0 - found

1) Sort in splunk is an odd duck. Unlike any other language, sort defaults to only return the first 10K results. So get in the habit of telling it to give you all results via sort 0, even if you are expecting fewer results than that.

2) As a matter of form, get in the habit of leaving a space between the minus and the field name. There are some splunk search commands that will allow them to be together like that, and some that won't, and better to make it visually obvious that the minus is an operator.


An alternative after the append that gets the same result might be...

 | stats count by eventtype 
 | where count=2
 | table eventtype

There's no particular efficiency reason to prefer one over the other, but this one might be more obvious to most beginners than the dedup version is.

0 Karma

adonio
Ultra Champion

use this search to find all eventtypes:

|rest servicesNS/-/-/saved/eventtypes
| table title

now you can go however you want, lookup and find with lookup command, sub search or other methods to find out which eventtypes are not captured

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 ...