Splunk Search

Convert a string into a number

Splunk Employee
Splunk Employee

I extracted some values into a field using the field extractor and now I need to convert it into a number to use sum() and avg(). It seems that this field's values is being recognized by Splunk as a string. I saw on the online docs the convert() function, but, not sure how to use it. Could you help?

Thanks a lot.

Tags (1)


I don't think if the field contains only number the arithmetic operations will take them as string, sum / avg should work.

How ever you can also use to convert to number :

isnum() also can be used to check the value if its number or not.

...|Convert num(filed) as Number_Filed also can be used


Super Champion

Try this:

search | convert num(fieldtoconvert)

This should convert the field you want to convert from a string to a number. All non-numbers will be removed. If you want to leave the non-numbers unchanged, then use:

search | convert auto(fieldtoconvert)

Get Updates on the Splunk Community!

Register to Attend BSides SPL 2022 - It's all Happening October 18!

Join like-minded individuals for technical sessions on everything Splunk!  This is a community-led and run ...

What's New in Splunk Cloud Platform 9.0.2208?!

Howdy!  We are happy to share the newest updates in Splunk Cloud Platform 9.0.2208! Analysts can benefit ...

Admin Console: A Single, Unified Interface for All Your Cloud Admin Needs

WATCH NOWJoin us to learn how the admin console can save you time and give you more control over the Splunk® ...