Splunk Search

Can I fix this tstats where error?

Imhim
Explorer

Hi, 

So i have this search: 

 

 

 

| tstats prestats=true count WHERE index=*_ot (source="*sgre*" OR o_wp="*sgre*") AND (source="*how02*" OR o_wp="*how02*") BY _indextime 
| eval _time=_indextime  | timechart count span=1h

 

 

 

 

Which gives me the error: 

 

 

 

When used for 'tstats' searches, the 'WHERE' clause can contain only indexed fields. Ensure all fields in the 'WHERE' clause are indexed. Properly indexed fields should appear in fields.conf.

 

 

 

 

Anyone know the solution to this? 

Labels (1)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust
index=*_ot (source="*sgre*" OR o_wp="*sgre*") AND (source="*how02*" OR o_wp="*how02*")
| stats count BY _indextime 
| eval _time=_indextime  
| timechart count span=1h

Or ensure all fields, e.g.  o_wp are indexed fields (going forward)

View solution in original post

gcusello
SplunkTrust
SplunkTrust

Hi @Imhim,

you can use tstats only on indexed fields, in your case o_wp shouldn't be an indexed field.

This means thatr you cannot use tstats for this search or add o_wp to the indexed fields.

or put all the fields you need for this dataset in a DataModel and use the datamodel for your search.

Ciao.

Giuseppe

Imhim
Explorer

Hi @gcusello

Thank you. 

If it needs to be an indexed field, then what would be the optimal approach to this? 

Br, 

Imhim 

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @Imhim,

you have three choices:

The best solution depends on your requirements: if you need performaces with many events you can use DataModels or Summary indexes.

Ciao.

Giuseppe

Imhim
Explorer

Thank you. I appreciate it 

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
index=*_ot (source="*sgre*" OR o_wp="*sgre*") AND (source="*how02*" OR o_wp="*how02*")
| stats count BY _indextime 
| eval _time=_indextime  
| timechart count span=1h

Or ensure all fields, e.g.  o_wp are indexed fields (going forward)

Get Updates on the Splunk Community!

How to Monitor Google Kubernetes Engine (GKE)

We’ve looked at how to integrate Kubernetes environments with Splunk Observability Cloud, but what about ...

Index This | How can you make 45 using only 4?

October 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with this ...

Splunk Education Goes to Washington | Splunk GovSummit 2024

If you’re in the Washington, D.C. area, this is your opportunity to take your career and Splunk skills to the ...