Splunk Search

Convert a string with percentage sign to a number so it can be evaluated?

charanramireddy
New Member

Hello,

I have this query to alert me when percentage_q_full reaches greater than certain number

eval alert=case((PERCENT_Q_FULL>90), "Critical", (PERCENT_Q_FULL>80), "Warning", true(), "N/A")

but all the column values of alert shows as N/A because PERCENT_Q_FULL has values in percentage. These values are being extracted using multikv.

PERCENT_Q_FULL
95.00%
3.12%
5.13%
0.00%
100.00%

How do I convert it so that alert column shows me critical vs warning ?

Thank you.

0 Karma
1 Solution

s2_splunk
Splunk Employee
Splunk Employee

Add | convert rmunit(PERCENT_Q_FULL) before your existing eval to remove the trailing unit character(s).

From the search reference manual:

rmunit()
Syntax: rmunit()
Description: Looks for numbers at the beginning of the value and removes trailing text. You can use wild card characters in the field name.

View solution in original post

s2_splunk
Splunk Employee
Splunk Employee

Add | convert rmunit(PERCENT_Q_FULL) before your existing eval to remove the trailing unit character(s).

From the search reference manual:

rmunit()
Syntax: rmunit()
Description: Looks for numbers at the beginning of the value and removes trailing text. You can use wild card characters in the field name.

charanramireddy
New Member

thank you. This works.

0 Karma
Get Updates on the Splunk Community!

Enterprise Security Content Update (ESCU) | New Releases

In December, the Splunk Threat Research Team had 1 release of new security content via the Enterprise Security ...

Why am I not seeing the finding in Splunk Enterprise Security Analyst Queue?

(This is the first of a series of 2 blogs). Splunk Enterprise Security is a fantastic tool that offers robust ...

Index This | What are the 12 Days of Splunk-mas?

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