Splunk Search

How to remove a column if only one column exists from a search?

brajaram
Communicator

I have a timechart that shows the timechart of errors in a timeframe.

index=......| eval error=if(apiHttpStatus!=200, apiErrorCode, "Success")
| bin span=1m _time
| stats count by _time, error
| eventstats sum(count) as total by _time
| eval perc=round((count*100)/total,2)
| timechart span=1m values(perc) by error

This correctly displays the timechart of the error in the given timeframe. However, I want to remove successes from the final view, but not from the count. If an error occurs 1% of the time, I don't want to see in the view that 99% of events are successes, but I can't filter out successes from the initial search. I've done this by adding

| timechart span=1m values(perc) by error
| fields - Success

After the timechart. However, this leads to the odd situation where if I have had no errors in the time window, the result is a table of time and nothing else, resulting in a weird visual. How do I remove all data (resulting in no results found) if the only results are successes?

Tags (3)
0 Karma
1 Solution

brajaram
Communicator

Found a really simple solution, feel dumb now. Just need to append | search error!=Success

index=......| eval error=if(apiHttpStatus!=200, apiErrorCode, "Success") | bin span=1m _time | stats count by _time, error | eventstats sum(count) as total by _time | eval perc=round((count*100)/total,2) | search error!=Success| timechart span=1m values(perc) by error

View solution in original post

0 Karma

brajaram
Communicator

Found a really simple solution, feel dumb now. Just need to append | search error!=Success

index=......| eval error=if(apiHttpStatus!=200, apiErrorCode, "Success") | bin span=1m _time | stats count by _time, error | eventstats sum(count) as total by _time | eval perc=round((count*100)/total,2) | search error!=Success| timechart span=1m values(perc) by error

0 Karma
Get Updates on the Splunk Community!

Enterprise Security Content Update (ESCU) | New Releases

In December, the Splunk Threat Research Team had 1 release of new security content via the Enterprise Security ...

Why am I not seeing the finding in Splunk Enterprise Security Analyst Queue?

(This is the first of a series of 2 blogs). Splunk Enterprise Security is a fantastic tool that offers robust ...

Index This | What are the 12 Days of Splunk-mas?

December 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...