Dashboards & Visualizations

How to get spl to look for the latest timestamp for all the sourcetypes?

Deepz2612
Explorer

Hi,

i have a set of sourcetypes in a lookup.

Now my spl has to look for the latest timestamp for all the sourcetypes in the last one hour and report for the sourcetype for which the events are not available in the last one hour

Labels (1)
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
| metadata type=sourcetypes
| where lastTime < relative_time(now(),"-1h")
0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @Deepz2612,

if you haven't to check if there are events with sourcetypes not in the lookup, you could run something like this:

index=* [ | inputlookup your_lookup | fields sourcetype ]
| stats count BY sourcetype
| append [ | inputlookup your_lookup | eval count=0 | fields sourcetype count ] 
| stats sum(count) AS total BY sourcetype
| where total=0

You could also use tstats to have a more performant search:

| tstats count WHERE index=* BY sourcetype
| search [ | inputlookup your_lookup | fields sourcetype ]
| append [ | inputlookup your_lookup | eval count=0 | fields sourcetype count ] 
| stats sum(count) AS total BY sourcetype
| where total=0

Ciao.

Giuseppe

0 Karma
Get Updates on the Splunk Community!

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

Splunk APM: New Product Features + Community Office Hours Recap!

Howdy Splunk Community! Over the past few months, we’ve had a lot going on in the world of Splunk Application ...