Splunk Search

How to change the format of the table output?

jgcsco
Path Finder

I have this search:

[search] | stats count by Status Errors | eventstats sum(count) as StatusCount by Status| eventstats sum(count) as TotalCount | search Status = "Failed" | eval percent=100*StatusCount/TotalCount | where percent > 1 | table percent Errors count

Which produces the following result:

percent   Error     count
1.2       error1      A
1.2       error2      B
1.2       error3      C

Since the percent here is the total error percent, I would like the result to show as the following:

percent  1.2
Error    count
error1     A
error2     B
error3     C

Or

Error    count    percent 1.2
error1     A
error2     B
error3     C

Can this be done?

Tags (3)
1 Solution

dwaddle
SplunkTrust
SplunkTrust

This is ugly, and not quite what you're looking for but ...

 $SEARCH | stats count by Status Errors 
| eventstats sum(count) as StatusCount by Status
| eventstats sum(count) as TotalCount | search Status = "Failed" 
| eval percent=100*StatusCount/TotalCount | where percent > 1 
| table percent Errors count
| appendpipe [ | stats max(percent) as count  | eval Errors="percent" ]
| fields - percent

View solution in original post

dwaddle
SplunkTrust
SplunkTrust

This is ugly, and not quite what you're looking for but ...

 $SEARCH | stats count by Status Errors 
| eventstats sum(count) as StatusCount by Status
| eventstats sum(count) as TotalCount | search Status = "Failed" 
| eval percent=100*StatusCount/TotalCount | where percent > 1 
| table percent Errors count
| appendpipe [ | stats max(percent) as count  | eval Errors="percent" ]
| fields - percent

jgcsco
Path Finder

Thanks, although a bit ugly, but it is very close to what I am looking for.

0 Karma

chimell
Motivator

Hi jgcsco
try this search code

     [search] | stats count by Status Errors | eventstats sum(count) as StatusCount by Status| eventstats sum(count) as TotalCount | table  Errors count|appendcols[search Status = "Failed" | eval percent=100*StatusCount/TotalCount | where percent > 1 |dedup percent| table percent] 
0 Karma

jgcsco
Path Finder

Thanks, I was wondering if there is a way to avoid using "appendcols".

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

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

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...