Splunk Search

Remove results from table if they do not meet a condition.

bravecarcass86
Engager

I am trying to create a search that will display all universal forwarders that have not checked in for over 24 hours. Currently, what I have will display all of them and only show the time since check in if it is only over 24 hours. How do I remove the results that do not meet this?

Here's what I have so far:

index=_internal sourcetype=splunkd group=tcpin_connections
| stats latest(version) as version by hostname
| join hostname [ | metadata type=hosts index=*
| eval last_seen_hours=case(((now()-lastTime)/60/60) > 1, (now()-lastTime)/60/60)
| table host, last_seen_hours
| rex field=host "(?[^.]+)" | fields - host ]
| sort last_seen_hours

Thank you for your help!

0 Karma
1 Solution

solarboyz1
Builder

Just add | search last_seen_hours > 24 to filter:

index=_internal sourcetype=splunkd group=tcpin_connections 
| stats latest(version) as version by hostname
| join hostname [ | metadata type=hosts index=* 
| eval last_seen_hours=case(((now()-lastTime)/60/60) > 1, (now()-lastTime)/60/60)
| search last_seen_hours > 24
| table host, last_seen_hours
| rex field=host "(?[^.]+)" | fields - host ] 
| sort last_seen_hours

View solution in original post

solarboyz1
Builder

Just add | search last_seen_hours > 24 to filter:

index=_internal sourcetype=splunkd group=tcpin_connections 
| stats latest(version) as version by hostname
| join hostname [ | metadata type=hosts index=* 
| eval last_seen_hours=case(((now()-lastTime)/60/60) > 1, (now()-lastTime)/60/60)
| search last_seen_hours > 24
| table host, last_seen_hours
| rex field=host "(?[^.]+)" | fields - host ] 
| sort last_seen_hours

bravecarcass86
Engager

Thanks, that works. I ended up just tacking on "| where last_seen_hours > 24" to the end, as that's the solution I found first. I appreciate the help though!

0 Karma
Get Updates on the Splunk Community!

Introducing the 2024 SplunkTrust!

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

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...