Splunk Search

How can we use predict command with tstats?

att35
Builder

Hi,

I have the following search that works against a datamodel to plot a timechart. How can I use predict command with this output?

 

 

| tstats summariesonly=true count FROM datamodel="modelname.dataset" where dataset.field="xyz"  by dataset.field, _time span=1h prestats=t  | timechart  span=1h count  by dataset.field usenull=f useother=f

 

 

If I try to do following,

 

 

| predict dataset.field

 

 

 search failed with this error.
command="predict", Unknown field: dataset.field
 
What is the correct way to do this?
 
UPDATE:
Turns out, | predict "xyz" works, but this would mean it is working just for that one value of the field.
 
Thanks
Labels (2)
Tags (3)
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

timechart is using dataset.field for values of field names in the y axis and doesn't exist any more - try predict count

0 Karma

att35
Builder

@ITWhisperer 

Same result.

command="predict", Unknown field: count

 

With timechart everything works fine, it plots using dataset.field or even with "field" after rename. But predict doesn't seem to be taking any option as input. Only way predict works here is if I use direct value of the field.

| predict value

 

0 Karma

richgalloway
SplunkTrust
SplunkTrust

Have you tried renaming the field?

| tstats summariesonly=true count FROM datamodel="modelname.dataset" where dataset.field="xyz"  by dataset.field, _time span=1h prestats=t  
| rename dataset.field as field
| timechart  span=1h count by field usenull=f useother=f
| predict field
---
If this reply helps you, Karma would be appreciated.
0 Karma

att35
Builder

Hi @richgalloway ,

Tried that but now it just gives same error message for field.

command="predict", Unknown field: field
0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...