Splunk Search

How to visualize count of messages between .. and .. MB, .. and .. MB etc.?

svester
New Member

Hi,
i want to see how many messages are send, which are between 0 and 1 mb, between 1MB and 2MB, 2 and 3 etc, but I can't even visualize 1 option 😞

I have this: index, host source etc.
| eval if((LENGTH >= 0 AND LENGTH <= 10000000), "Between 0MB en 1MB", "Rest")
| stats count(LENGTH)

Note: LENGTH= shown like this: [LENGTH=365] and is an interesting field (num), shown in bytes.

So i have 2 questions:
- I receive this error with above eval: *Error in 'eval' command: Type checking failed. 'AND' only takes boolean arguments. *
What is wrong with this argument?
- And can someone help me fixing this visualization?

Tags (1)
0 Karma
1 Solution

nickhills
Ultra Champion

The first issue is that your eval syntax is not quite right. Use:

|eval size=if((LENGTH >= 0 AND LENGTH <= 10000000), "Between 0MB en 1MB", "Rest")
| stats count(size)

although case may be a better choice in this scenario.

|eval size=case((LENGTH >= 0 AND LENGTH <= 10000000), "0MB - 1MB", (LENGTH >= 10000001 AND LENGTH <= 20000000), "1MB - 2MB",(LENGTH >= 20000001 AND LENGTH <= 30000000), "2MB - 3MB",1=1, "Bigger")
| stats count(size)
If my comment helps, please give it a thumbs up!

View solution in original post

0 Karma

nickhills
Ultra Champion

The first issue is that your eval syntax is not quite right. Use:

|eval size=if((LENGTH >= 0 AND LENGTH <= 10000000), "Between 0MB en 1MB", "Rest")
| stats count(size)

although case may be a better choice in this scenario.

|eval size=case((LENGTH >= 0 AND LENGTH <= 10000000), "0MB - 1MB", (LENGTH >= 10000001 AND LENGTH <= 20000000), "1MB - 2MB",(LENGTH >= 20000001 AND LENGTH <= 30000000), "2MB - 3MB",1=1, "Bigger")
| stats count(size)
If my comment helps, please give it a thumbs up!
0 Karma

svester
New Member

Thanks, I added "by size" to make the visualization better.

 | stats count(size) by size
0 Karma

nickhills
Ultra Champion

Great, Glad to have helped.

If my comment helps, please give it a thumbs up!
0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Splunk AI Assistant for SPL vs. ChatGPT: Which One is Better?

In the age of AI, every tool promises to make our lives easier. From summarizing content to writing code, ...

Data Persistence in the OpenTelemetry Collector

This blog post is part of an ongoing series on OpenTelemetry. What happens if the OpenTelemetry collector ...

Thanks for the Memories! Splunk University, .conf25, and our Community

Thank you to everyone in the Splunk Community who joined us for .conf25, which kicked off with our iconic ...