Splunk Search

Tstats with a different field

curry59
New Member

Hello,

I recently setup a summary index. I'm searching with "tstats" in that summary index to get a single integer of the associated servers that are up/down. My search works with "host=($SERVERNAME)", but I would like to use a different field than "host" which would be "orig_host". Below is my search that works with "host", but seem to cant get it working with "orig_host" instead of "host". Does "tstats" only work with host, source and sourcetype only?

| tstats latest(_time) as latest where host=($SERVERNAME) by host
| eval noDataTime = now() - latest
| eval status = if(noDataTime>600,"HOST DOWN" ,if(noDataTime>300,"Warning","Available"))
| stats count(eval(status="Available")) AS Available

Thank you!

0 Karma
1 Solution

rjthibod
Champion

Tstats only works with the index-time fields and the raw data.

So, unless you are setting up "orig_host" as an index-time field, your only chance to include the raw search text for the "orig_host" field. Still, you are limited to just searching the raw text string of "($SERVERNAME)". You get no guarantees because tstats will return the value for any event that includes that string.

| tstats latest(_time) as latest where "($SERVERNAME)" by host

View solution in original post

0 Karma

rjthibod
Champion

Tstats only works with the index-time fields and the raw data.

So, unless you are setting up "orig_host" as an index-time field, your only chance to include the raw search text for the "orig_host" field. Still, you are limited to just searching the raw text string of "($SERVERNAME)". You get no guarantees because tstats will return the value for any event that includes that string.

| tstats latest(_time) as latest where "($SERVERNAME)" by host

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