Splunk Search

stats count by sourcetype,date_hour wrong results

mauro_vaccari
New Member

Hi all,

We have installed splunk 6.0.1.
when we try to use stats count by source type we have a results of all 8 sourcetype we have. If we combine sourcetype and date_hour we have a results of only two sourcetype

It's correct or some goes wrong?
This are search I'm using

earliest=-2h@h latest=@h | stats count by sourcetype

WinEventLog:Application 5269
WinEventLog:Security 2138
WinEventLog:System 345
WinEventLog:application 12408
WinEventLog:security 9347
WinEventLog:system 286
linux_messages 16066
vmw-esx 32392

earliest=-2h@h latest=@h | stats count by sourcetype,date_hour

linux_messages 14 6535
linux_messages 15 9536
vmw-esx 12 24669
vmw-esx 13 7723

Thanks

Tags (2)
0 Karma
1 Solution

martin_mueller
SplunkTrust
SplunkTrust

Those Windows sourcetypes probably don't have the field date_hour - that only exists if the timestamp is properly extracted from the event, I remember Windows sourcetypes might use indextime assignment instead. Try this as an alternative:

earliest=-2h@h latest=@h | bin span=1h _time | stats count by sourcetype _time

Slightly different point, but counting by sourcetype can be done much faster using tstats.

| tstats count by sourcetype _time span=1h

View solution in original post

0 Karma

martin_mueller
SplunkTrust
SplunkTrust

Those Windows sourcetypes probably don't have the field date_hour - that only exists if the timestamp is properly extracted from the event, I remember Windows sourcetypes might use indextime assignment instead. Try this as an alternative:

earliest=-2h@h latest=@h | bin span=1h _time | stats count by sourcetype _time

Slightly different point, but counting by sourcetype can be done much faster using tstats.

| tstats count by sourcetype _time span=1h
0 Karma

mauro_vaccari
New Member

Thanks, your search works perfectly, we try to use tstats. Thank you

0 Karma
Get Updates on the Splunk Community!

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 ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...