Splunk Search

How to use the bin command?

amarish_vlabs
New Member

Hi Team,

I have a field which takes values from 1 to 100. So I want use the bin command in such a way so the output should be like 1-10, 11-20, 21-30, 31-40 ..............99-100

Output:

1-10            13
11-20            9
21-30           21
31-40            5
................................
................................
................................

91-100           3

Please suggest

Thanks in advance,
Amarish

Tags (1)
0 Karma
1 Solution

diogofgm
SplunkTrust
SplunkTrust

Use this:
| bin field_name bins=10 | stats count by field_name

More information on bins from docs here (check the Example 2 in docs).

------------
Hope I was able to help you. If so, some karma would be appreciated.

View solution in original post

diogofgm
SplunkTrust
SplunkTrust

Use this:
| bin field_name bins=10 | stats count by field_name

More information on bins from docs here (check the Example 2 in docs).

------------
Hope I was able to help you. If so, some karma would be appreciated.

jeffland
SplunkTrust
SplunkTrust

Actually, using bins=10 will produce ten bins, so if your range is from 0 to 1000, your first bin will be 0-100, the next 100-200 and so on - use span=10 to have bins with a length of 10 each, no matter your range.

0 Karma

amarish_vlabs
New Member

Thank you so much for your reply. I have used your query and got the output like 0-10 , 10-20, 20-30.....etc. But I want to see the out put like 0-10 , 11-20, 21-30 , 31-40 .......etc. Please let me know Is this possible ?

Thanks,
Amarish

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