Splunk Search

How to achieve stats count eval chart?

djoobbani
Path Finder

Dear Splunk community:

 

I have the following search query:

<BASIC_SEARCH> | chart count by path_template, http_status_code | addtotals fieldname=total
| foreach 2* 3* 4* 5* [ eval "percent_<<FIELD>>"=round(100*'<<FIELD>>'/total,2),
"<<FIELD>>"=if('<<FIELD>>'=0 , '<<FIELD>>', '<<FIELD>>'." (".'percent_<<FIELD>>'."%)")] | fields - percent_* total

Attached is a sample of the current output based on the above search.

I am trying to do the same thing except only show the 500, 502,503 columns (but still do all the calculation based on the total count of everything). How do i change the above search to achieve this?

Thanks,

Daryoush

Labels (1)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

Have you tried removing the unwanted fields?

<BASIC_SEARCH> | chart count by path_template, http_status_code 
| addtotals fieldname=total
| foreach 2* 3* 4* 5* [ eval 
  "percent_<<FIELD>>"=round(100*'<<FIELD>>'/total,2),
  "<<FIELD>>"=if('<<FIELD>>'=0 , '<<FIELD>>', '<<FIELD>>'." 
  (".'percent_<<FIELD>>'."%)")] 
| fields - percent_* total 2* 3* 4*
---
If this reply helps you, Karma would be appreciated.

View solution in original post

richgalloway
SplunkTrust
SplunkTrust

Have you tried removing the unwanted fields?

<BASIC_SEARCH> | chart count by path_template, http_status_code 
| addtotals fieldname=total
| foreach 2* 3* 4* 5* [ eval 
  "percent_<<FIELD>>"=round(100*'<<FIELD>>'/total,2),
  "<<FIELD>>"=if('<<FIELD>>'=0 , '<<FIELD>>', '<<FIELD>>'." 
  (".'percent_<<FIELD>>'."%)")] 
| fields - percent_* total 2* 3* 4*
---
If this reply helps you, Karma would be appreciated.

djoobbani
Path Finder

Yes this works, thank u very much!

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Community Content Calendar, September edition

Welcome to another insightful post from our Community Content Calendar! We're thrilled to continue bringing ...

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...