Splunk Search

Using Eval where

tb5821
Communicator

I'm doing something wrong here.. . I have the following search

...| eval SuccessRatio =  (round(((succeeded_count)/(task_count)) * 100)). "%" | search SuccessRatio < 98 |  sort SuccessRatio

I'm trying to filter out anything that has a SuccessRatio of greater than 98% but its not working I'm still getting results that have 100% success.

Tags (3)
0 Karma

gkanapathy
Splunk Employee
Splunk Employee

because you appended "%" to the number before filtering, making it a string (not a number). SuccessRatio is not a number, it's a string. eval, filter, sort, and then format it:

  ... | eval SuccessRatio = round(100*succeeded_count/task_count) | where SuccessRatio < 98 | sort SuccessRatio | eval SuccessRatio = SuccessRatio . "%"

davecroto
Splunk Employee
Splunk Employee

Did you ever get this to work?

0 Karma

davecroto
Splunk Employee
Splunk Employee

Test to see if succeeded_count and task count are actually numbers. Other than that, I cannot see why this would not work

0 Karma

davecroto
Splunk Employee
Splunk Employee

*|eval succeeded_count=99 |eval task_count=1| eval SuccessRatio = (round(((succeeded_count)/(task_count)) * 100)). "%" | search SuccessRatio < 98 | sort SuccessRatio

vs

*|eval succeeded_count=20 |eval task_count=1| eval SuccessRatio = (round(((succeeded_count)/(task_count)) * 100)). "%" | search SuccessRatio < 98 | sort SuccessRatio

Seems to work for the above

0 Karma
Get Updates on the Splunk Community!

Index This | Why did the turkey cross the road?

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

Enter the Agentic Era with Splunk AI Assistant for SPL 1.4

  &#x1f680; Your data just got a serious AI upgrade — are you ready? Say hello to the Agentic Era with the ...

Feel the Splunk Love: Real Stories from Real Customers

Hello Splunk Community,    What’s the best part of hearing how our customers use Splunk? Easy: the positive ...