Security

How to restrict timerange in tstats search within query?

DEAD_BEEF
Builder

I have a tstats search panel on a dashboard and I'm trying to limit the timeframe for this particular search (separate from the shared time token). I tried using various commands but just can't seem to get the syntax right. What is the correct syntax to specify time restrictions in a tstats search?

current search query is not limited to the 3 hours, it still runs to whatever the time picker selects.

| tstats hoursago=4 endhoursago=1 count where index=web by _time sourcetype span=15m prestats=t
| timechart span=15m count by sourcetype
0 Karma
1 Solution

renjith_nair
Legend

@DEAD_BEEF,

Try this

| tstats count where (index=_internal earliest=-4h  latest=-1h)  by _time sourcetype span=15m prestats=t
| timechart span=15m count by sourcetype
---
What goes around comes around. If it helps, hit it with Karma 🙂

View solution in original post

renjith_nair
Legend

@DEAD_BEEF,

Try this

| tstats count where (index=_internal earliest=-4h  latest=-1h)  by _time sourcetype span=15m prestats=t
| timechart span=15m count by sourcetype
---
What goes around comes around. If it helps, hit it with Karma 🙂

DEAD_BEEF
Builder

works perfectly! I was so close, I tried earliest/latest in the timechart command, thank you!

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