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!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

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

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...