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!

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...

New in Observability Cloud - Explicit Bucket Histograms

Splunk introduces native support for histograms as a metric data type within Observability Cloud with Explicit ...