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!

Introducing Splunk Enterprise 9.2

WATCH HERE! Watch this Tech Talk to learn about the latest features and enhancements shipped in the new Splunk ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...