Splunk Search

Why does timewrap require timechart results?

tiimo
Engager

If you use timewrap without previously using the timechart command, you get a warning "The timewrap command is designed to work on the output of timechart. ".

If the format is correct, it works though.

For example, these two queries give the same output:

| tstats count where index=my_index by _time span=1h
| timewrap 1w
index=my_index
| timechart span=1h count 
| timewrap 1w

 The first query is way faster in this case, but I get the warning mentioned above. (this is not about the tstats command, it is also possible to recreate timechart it with other commands iirc)

The docs say: "You must use the timechart command in the search before you use the timewrap command. " (both SPL and SPL2 docs say this)

Why is this the case though? Beside the docs and the warning, nothing hints towards this being correct, it works...

Am I missing something? If not, is it possible to deactivate the warning?

 

Labels (1)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

timewrap is looking for a hidden field called _span

This should work

| tstats count where index=my_index by _time span=1h
| eval _span=3600
| timewrap 1w

 This should give a warning

index=my_index
| timechart span=1h count 
| fields - _span
| timewrap 1w

View solution in original post

isoutamo
SplunkTrust
SplunkTrust

You could also use tstats with prestats=t paramter like

| tstats prestats=t count where index=my_index by _time span=1h
| timechart span=1h count
| timewrap 1w

 https://docs.splunk.com/Documentation/Splunk/9.4.2/SearchReference/Tstats

 

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

timewrap is looking for a hidden field called _span

This should work

| tstats count where index=my_index by _time span=1h
| eval _span=3600
| timewrap 1w

 This should give a warning

index=my_index
| timechart span=1h count 
| fields - _span
| timewrap 1w

tiimo
Engager

Huh, thanks, that works. This should be changed or at least clarified in the documentation

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

If all these things were documented, there wouldn't be a need for Answers, Splunk Trust and .conf! 🤣

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