Splunk Search

How to show percentages calculated by totals

ivana27
Path Finder

Hi Splunkers,

please help. I have search where i want to show percentages by host of how many errors (mentioned below) occured on host comparing with other hosts. This is my search, and i get results for all hosts 100%

index=pkg_dummy host IN (*) "[Error] POS Card Validation - Result: Timeout"
| eval host=host | dedup _raw
| rex "\[Error\]\sPOS\sCard\sValidation\s\-\sResult:\s(?<timeout>Timeout)"
| stats count by host AS "TOTAL"
| stats count(eval(timeout)) AS NOK_Transaction by host
| eval FailedTr = round((NOK_Transaction / TOTAL *100),2), FailedTr = FailedTr + "%"
| table host FailedTr
| sort FailedTr desc

Thank you

Labels (2)
0 Karma
1 Solution

ivana27
Path Finder

My bad, i found solution, trick was in 

| eventstats sum(count) as TOTAL

Thank you for quick feedback

View solution in original post

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

I am surprised you get anything

| stats count by host AS "TOTAL"

if the wrong syntax and even if it was

| stats count AS "TOTAL" by host

You are left with two columns (host and count) which means 

| stats count(eval(timeout)) AS NOK_Transaction by host

Will return zeros

Please clarify what you are actually trying

ivana27
Path Finder

My bad, i found solution, trick was in 

| eventstats sum(count) as TOTAL

Thank you for quick feedback

0 Karma
Get Updates on the Splunk Community!

Get the T-shirt to Prove You Survived Splunk University Bootcamp

As if Splunk University, in Las Vegas, in-person, with three days of bootcamps and labs weren’t enough, now ...

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...

Wondering How to Build Resiliency in the Cloud?

IT leaders are choosing Splunk Cloud as an ideal cloud transformation platform to drive business resilience,  ...