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!

Updated Team Landing Page in Splunk Observability

We’re making some changes to the team landing page in Splunk Observability, based on your feedback. The ...

New! Splunk Observability Search Enhancements for Splunk APM Services/Traces and ...

Regardless of where you are in Splunk Observability, you can search for relevant APM targets including service ...

Webinar Recap | Revolutionizing IT Operations: The Transformative Power of AI and ML ...

The Transformative Power of AI and ML in Enhancing Observability   In the realm of IT operations, the ...