Splunk Search

How to convert my two searches into tstats searches?

Robel206
New Member

Hey everyone,

I need a little assistance converting these 2 searches (one is a pivot search) I have into tstats searches.

  1. | pivot Expweb_Tracelog_Service Service_Events count(Service_Events) AS "Count of Service_Events" SPLITROW _time AS _time PERIOD auto SPLITCOL eventName FILTER eventName is service:SoftvoyageService* FILTER success is false SORT 100 _time ROWSUMMARY 0 COLSUMMARY 0 NUMCOLS 100 SHOWOTHER 1

  2. index = exp sourcetype = expwebtracelog splunk_server_group = ewe host = cheXwbtexweb10* eventName=service:SoftvoyageService* OR eventName=ThreePP* | stats count AS Total count(eval(success="true")) AS Successful count(eval(success="false")) AS Failed by eventName | eval "SuccessPercent"=(Total-Failed)/Total*100

Thanks,

0 Karma
1 Solution

jplumsdaine22
Influencer

You'll only be able to use tstats if the fields are indexed. By default, that is host, source, sourcetype and _time. If eventName and success are search time fields then you will not be able to use tstats.

You can quickly check by running the following search

| tstats count WHERE sourcetype = expwebtracelog (eventName=* OR success=*) by eventName,success

If you get no results then these are not indexed fields.

If your data model is accelerated you might be able to use tstats for your first query, try

| tstats prestats=t count(Service_Events)  WHERE eventName=service:SoftvoyageService* AND success=false FROM Expweb_Tracelog_Service Service_Events by _time | timechart AS count(Service_Events) "Count of Service_Events" | head 100

View solution in original post

0 Karma

jplumsdaine22
Influencer

You'll only be able to use tstats if the fields are indexed. By default, that is host, source, sourcetype and _time. If eventName and success are search time fields then you will not be able to use tstats.

You can quickly check by running the following search

| tstats count WHERE sourcetype = expwebtracelog (eventName=* OR success=*) by eventName,success

If you get no results then these are not indexed fields.

If your data model is accelerated you might be able to use tstats for your first query, try

| tstats prestats=t count(Service_Events)  WHERE eventName=service:SoftvoyageService* AND success=false FROM Expweb_Tracelog_Service Service_Events by _time | timechart AS count(Service_Events) "Count of Service_Events" | head 100
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 ...