Splunk Search

How to modify my search in order to create stacked bar chart that shows errors, exceptions, or timeouts?

Kumar1980
New Member

HI ,

I am new to using Splunk Enterprise and not so familiar with the search strings and other stuff 🙂

here is my requirement :

search the logs for errors/exceptions/timeout/etc... and display it as a stacked bar view with color code

example: error - Red exception - green etc...

Y axis should have the count and X - axis should have source type

the resulting bar representation should show error/exception etc .. in stacked form with different colors, once we click on colors it should take us to the corresponding logs with the specific error/exception etc ...

Here is the search string :

index=**  host=* source=logs AND ("ERROR" OR "exception" OR "timeout") | TOP sourcetype 

please suggest as this is something important for my ongoing project

0 Karma
1 Solution

sundareshr
Legend

Try this

index=**  host=* source=logs AND ("ERROR" OR "exception" OR "timeout") | rex "(?<err>ERROR|exception|timeout)" | chart count over host by err usenull=f

View solution in original post

0 Karma

sundareshr
Legend

Try this

index=**  host=* source=logs AND ("ERROR" OR "exception" OR "timeout") | rex "(?<err>ERROR|exception|timeout)" | chart count over host by err usenull=f
0 Karma

Kumar1980
New Member

Thanks Sundaresh,

This is getting me results but they are partial only

i can see a stacked bar with two colors, one of which is errors/exceptions (Bluish color) and the other is an orange/yellowish color which says null and clicking on it leads no where

Y axis should show the count and the stacked bar should have errors/exceptions/timeout etc... stacked with different colors

Unable to attach an image which represents this idea , which would have given a clear picture

Please suggest the changes to complete this 🙂 Thanks for your help

  • Praneeth
0 Karma

sundareshr
Legend

What do you get when you run this search. Also, can you share sample event with each of the error code (ERROR, exception, timeout).

index=**  host=* source=logs AND ("ERROR" OR "exception" OR "timeout") | rex "(?<err>ERROR|exception|timeout)" | table _time host err
0 Karma

Kumar1980
New Member

HI Sundaresh,

I did get good results now with the first string that you have provided and thanks a lot (might be some mistake at my end)

Just a last concern ... as mentioned today i see lot of NULL in the bars .. clicking it leads nowhere, is it possible to remove it or hide it from the search results

  • Praneeth
0 Karma

sundareshr
Legend

Add usenull=f to the chart command. I've updated the original answer

0 Karma

Kumar1980
New Member

Perfect 🙂

Will get back to you if i have any questions on my upcoming project

0 Karma

sundareshr
Legend

Please accept this answer to close it out

0 Karma
Get Updates on the Splunk Community!

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...

.conf24 | Personalize your .conf experience with Learning Paths!

Personalize your .conf24 Experience Learning paths allow you to level up your skill sets and dive deeper ...

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...