Splunk Search

Why does tstats command alter time stamps when I run it by _time?

LIS
Path Finder

I am wondering why tstats command alters time stamps when I run it by _time.

| tstats values(text_len) as text_len  values(ts) as ts where index = data sourcetype = cdr by _time thread_id num_attempts

raw data in index=data :  

Time   _time 2023-03-22T13:14:16.000+01:00

 

LIS_0-1679491403739.png

After tstats:

2023-03-22 13:10:00

LIS_1-1679491530559.png

 

 

 

Labels (1)
Tags (1)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

To group events by _time, tstats rounds the _time value down to create groups based on the specified span.  If no span is specified, tstats will pick one that fits best in the time window search - 10 minutes in this case.

---
If this reply helps you, Karma would be appreciated.

View solution in original post

richgalloway
SplunkTrust
SplunkTrust

To group events by _time, tstats rounds the _time value down to create groups based on the specified span.  If no span is specified, tstats will pick one that fits best in the time window search - 10 minutes in this case.

---
If this reply helps you, Karma would be appreciated.

qs_chuy
Engager

I ran into the same thing, but I noticed that when I run my queries against a data model that is not accellerated, I get the right results.

Is there a reason why running against a datamodel that is accelerated and the same data model that is not accelerated yield different results?

0 Karma

richgalloway
SplunkTrust
SplunkTrust

This thread is more than a year old so you are more likely to get responses by submitting a new question.

---
If this reply helps you, Karma would be appreciated.

LIS
Path Finder

Hi @richgalloway 

 

Thank you for your response. But in my case there are no groups, because i used also another field (id) in by section, which is unique. So I expected to see all events with their original timestamps.

0 Karma

bowesmana
SplunkTrust
SplunkTrust

tstats by _time supports the span= argument, so you can do span=1s to get the a 1 second bucket of _time

 

yeahnah
Motivator

Hi @LIS 

@richgalloway  is correct, it's due to grouping by the _time field.

If you do want to pull the original _time out of the event then do not group by _time but pull it out as a field value, e.g.

| tstats max(_time) AS _time values(text_len) as text_len  values(ts) as ts where index = data sourcetype = cdr by thread_id num_attempts 

 This assumes that each event has a unique thread_id and num_attempts, but hopefully this demonstrates the difference in what you expected.

richgalloway
SplunkTrust
SplunkTrust

tstats still would have modified the timestamps in anticipation of creating groups.  It wouldn't know that would fail until it was too late.

If this was a stats command then you could copy _time to another field for grouping, but I don't know of a way to do that with tstats.

---
If this reply helps you, Karma would be appreciated.
Get Updates on the Splunk Community!

What's New in Splunk Enterprise 9.4: Features to Power Your Digital Resilience

Hey Splunky People! We are excited to share the latest updates in Splunk Enterprise 9.4. In this release we ...

Take Your Breath Away with Splunk Risk-Based Alerting (RBA)

WATCH NOW!The Splunk Guide to Risk-Based Alerting is here to empower your SOC like never before. Join Haylee ...

SignalFlow: What? Why? How?

What is SignalFlow? Splunk Observability Cloud’s analytics engine, SignalFlow, opens up a world of in-depth ...