Splunk Search

How to get stats count to include zero count by time?

lukas
Loves-to-Learn

Hi,
I have a lookup file like this -

users:
User1
User2
User3
User4
...


I need to count the events by user:

index=myindex 
| stats count as count by user
| inputlookup append=true userlist.csv
| fillnull count
| stats sum(count) as count by user
| table user count

It shows me the number of events per user in the CSV file.
If a user has no events, the count is 0:

usercount
User12593
User2301
User30
User41284

 

But I need the output additionally splitted over time (span=1h).
The output should look like this:

timeusercount
11.08.2020 11:00:00.000 User11023
11.08.2020 11:00:00.000User2190
11.08.2020 11:00:00.000User30
11.08.2020 11:00:00.000User41284
11.08.2020 12:00:00.000User11570
11.08.2020 12:00:00.000User2111
11.08.2020 12:00:00.000User30
11.08.2020 12:00:00.000User40
time + 1h......

 

I saw few other questions in splunk answers but they didnt work for me...
I hope you could help me. Thank a lot!

Labels (6)
Tags (2)
0 Karma

richgalloway
SplunkTrust
SplunkTrust

Perhaps this will help.

index=myindex 
| stats count as count by user
| inputlookup append=true userlist.csv
| fillnull count
| timechart span=1h sum(count) as count by user
| table user count
---
If this reply helps you, Karma would be appreciated.
0 Karma

lukas
Loves-to-Learn

Thanks for the feedback. Unfortunately it does not work, if I use the timechart command like this, I do not get any results back.

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas     Cisco Live 2026 is almost here, and this ...

What Is the Name of the USB Key Inserted by Bob Smith? (BOTS Hint, Not the Answer)

Hello Splunkers,   So you searched, “what is the name of the usb key inserted by bob smith?”  Not gonna lie… ...

Automating Threat Operations and Threat Hunting with Recorded Future

    Automating Threat Operations and Threat Hunting with Recorded Future June 29, 2026 | Register   Is your ...