Splunk Search

Adding a percentage Failure column to a table from a chart command

zd00191
Communicator

I have the following search.

index=ko_autosys sourcetype=autosys_applog_scheduler_events  host="usatlb98" OR host="usatlb91" System="*"  JOB_NAME="*" eventtype=autosys_failure_jobs OR eventtype=autosys_terminated_jobs OR eventtype=autosys_restart_jobs OR eventtype=autosys_success_jobs |chart count(JOB_NAME) over System by job_status |rename System as "Application" |sort 0 -FAILURE |addtotals fieldname=Total

This search creates a table with a total column and a column for each status. Each column contains a numerical value which is a count. I would like to add a column that will show the percentage of the 'Total' column that the FAILURE column count is . For example if the Total column for SAP FILO is 100 and the failure column value is 20. I wan to have another column that will have 20%. Please help! Thanks!

0 Karma
1 Solution

woodcock
Esteemed Legend

OK, given your clarification, like this:

 index=ko_autosys sourcetype=autosys_applog_scheduler_events  host="usatlb98" OR host="usatlb91" System="*"  JOB_NAME="*" eventtype=autosys_failure_jobs OR eventtype=autosys_terminated_jobs OR eventtype=autosys_restart_jobs OR eventtype=autosys_success_jobs | chart count(JOB_NAME) over System by job_status |rename System as "Application" | sort 0 -FAILURE | addtotals fieldname=Total | eval pct=100*FAILURE/Total

View solution in original post

woodcock
Esteemed Legend

OK, given your clarification, like this:

 index=ko_autosys sourcetype=autosys_applog_scheduler_events  host="usatlb98" OR host="usatlb91" System="*"  JOB_NAME="*" eventtype=autosys_failure_jobs OR eventtype=autosys_terminated_jobs OR eventtype=autosys_restart_jobs OR eventtype=autosys_success_jobs | chart count(JOB_NAME) over System by job_status |rename System as "Application" | sort 0 -FAILURE | addtotals fieldname=Total | eval pct=100*FAILURE/Total

woodcock
Esteemed Legend

Like this:

index=ko_autosys sourcetype=autosys_applog_scheduler_events  host="usatlb98" OR host="usatlb91" System="*"  JOB_NAME="*" eventtype=autosys_failure_jobs OR eventtype=autosys_terminated_jobs OR eventtype=autosys_restart_jobs OR eventtype=autosys_success_jobs |chart count(JOB_NAME) over System by job_status |rename System as "Application" | addcoltotals | fillnull value="Total" | eval rowTotal=0 | foreach * [eval rowTotal = rowTotal + if(isnum(<<FIELD>>),<<FIELD>>,0)] | sort 6 - rowTotal | eventstats first(rowTotal) AS allTotal | eval pct = 100*rowTotal/allTotal |sort 0 -FAILURE
0 Karma

zd00191
Communicator

Thank you again for helping me.

The table should contain 20 rows with the last row being a sum of the column values. There should be 6 columns with the last column containing a total of the row. I would like to have a column that displays a percentage of the total that is in the FAILURE column. These should be the column separated by a space

Application FAILURE RESTART SUCCESS TERMINATED Total PercentFailure

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Index This | What travels the world but is also stuck in place?

April 2026 Edition  Hayyy Splunk Education Enthusiasts and the Eternally Curious!   We’re back with this ...

Discover New Use Cases: Unlock Greater Value from Your Existing Splunk Data

Realizing the full potential of your Splunk investment requires more than just understanding current usage; it ...

Continue Your Journey: Join Session 2 of the Data Management and Federation Bootcamp ...

As data volumes continue to grow and environments become more distributed, managing and optimizing data ...