Splunk Search

Different results when using bucket _time and timechart

rosho
Communicator

Hello
I want to count the number of logins by hour and then try to predict them.
I have tested 2 codes but I do not know why there is a difference in results.

This code gives me 741 results:

|index=fortigate
|bucket _time span=1h
|stats count by _time

This code gives me 744 results:

|index=fortigate
|timechart span=1h count(status) as logins

Thank you.

0 Karma
1 Solution

jnudell_2
Builder

Hi @rosho ,

The stats version will discard time range buckets where the count is 0. Timechart will include these timeranges (and therefore the result count will be different). Additionally in your timechart command you're putting in a count of statuses and setting it to logins. You're not doing the same thing for the stats command.

View solution in original post

jnudell_2
Builder

Hi @rosho ,

The stats version will discard time range buckets where the count is 0. Timechart will include these timeranges (and therefore the result count will be different). Additionally in your timechart command you're putting in a count of statuses and setting it to logins. You're not doing the same thing for the stats command.

Get Updates on the Splunk Community!

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...