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!

Updated Team Landing Page in Splunk Observability

We’re making some changes to the team landing page in Splunk Observability, based on your feedback. The ...

New! Splunk Observability Search Enhancements for Splunk APM Services/Traces and ...

Regardless of where you are in Splunk Observability, you can search for relevant APM targets including service ...

Webinar Recap | Revolutionizing IT Operations: The Transformative Power of AI and ML ...

The Transformative Power of AI and ML in Enhancing Observability   In the realm of IT operations, the ...