Splunk Search

How to edit my eval statement to convert numerical values from a field into MB?

asarran
Path Finder

I have a field [B] that consists of some numbers and strings.

10 gb
20 gb 
30 gb 

I would like to implement a eval statement that would convert the numerical values into MB.

B=*"GB"| eval GB=*/1024 | table GB 

I'm not sure what is incorrect about this statement?

Tags (2)
0 Karma

lweber
Path Finder

if you have a 'string' field, first get the numeric value (i am using the rex command here)
then multiply the extracted value (field: numericB) with 1024 to get the MB...

| rex field=B "\D?(?<numericB>\d*)\D?" 
| eval MB=numericB*1024
| table MB
0 Karma
Get Updates on the Splunk Community!

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer at Splunk .conf24 ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

Splunk Lantern is Splunk’s customer success center that provides advice from Splunk experts on valuable data ...