Splunk Search

converting an triming field values

codedtech
Path Finder

I need to to convert this field in to a number and remove the $ capacity_gb = $8,191.75, I've tried eval to num and convert, but nothing worked.

0 Karma

vnravikumar
Champion

Hi

Try this

| makeresults 
| eval capacity_gb = "$8,191.75" 
| eval capacity_gb = replace(capacity_gb,"\$","")
0 Karma

renjith_nair
SplunkTrust
SplunkTrust

@codedtech .

Try

|rex mode=sed field=capacity_gb "s/[^\d\.]//g"

If you need , also part of you value, just add , to the square bracket

Happy Splunking!
0 Karma

richgalloway
SplunkTrust
SplunkTrust

To clarify, what do you get from | eval x = tonumber(capacity_gb) | table capacity_gb x ?

---
If this reply helps you, Karma would be appreciated.
0 Karma

codedtech
Path Finder

Yes, and the output is displayed like this:
capacity_gb x
$8,191.75

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

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

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...