Splunk Search

How to convert KB to MB?

jip31
Motivator

Hi
I need to convert these 2 counters from KB to MB
TotalSpaceKB=486757372
FreeSpaceKB=435455092
Do I have to divide this by 1024000?
thanks

0 Karma
1 Solution

493669
Super Champion

yes to convert KB to MB divide by 1024-

...| eval TotalSpaceMB=TotalSpaceKB/1024

and similarly,

...| eval FreeSpaceMB=FreeSpaceKB/1024

View solution in original post

0 Karma

493669
Super Champion

yes to convert KB to MB divide by 1024-

...| eval TotalSpaceMB=TotalSpaceKB/1024

and similarly,

...| eval FreeSpaceMB=FreeSpaceKB/1024
0 Karma

jip31
Motivator

Ok thanks
And if i want to convert the MB in GB i divise by 1000?
I have done this, is it ok??

index="perfmon" sourcetype=WinHostMon 
| eval TotalSpace =  TotalSpaceKB/1024
| eval FreeSpace = FreeSpaceKB/1024
| eventstats first(TotalSpace) as TotalSpace,first(FreeSpace) as FreeSpace 
| eval FreeSpace = round(FreeSpace/1000,1)
| eval TotalSpace = round(TotalSpace/1000,1)
| eval FreePerc = round((FreeSpace/TotalSpace)*100,1)
| eval DiskSpace = TotalSpace." GB". " (Total) ". FreeSpace." GB". " (Free) ". FreePerc." %". " (Free %) "
| table host DiskSpace
0 Karma

493669
Super Champion

to convert MB to GB , divide by 1024
and I don't think you will require to use eventstats command

0 Karma

pramit46
Contributor

@jip31, you can keep this formula handy for future calculations:

1Terabytes = 1024Gigabytes
1Gigabytes = 1024Megabytes
1Megabytes = 1024Kilobytes
1Kilobytes = 1024Bytes
1Byte = 8Bits

You go downwards, you multiply by the number on the right side.
You go upwards, you divide by the number on the right side.

eg: 1
10 GB = 10*1024 MB
10 MB = 10/1024 GB

makes sense? Just keep in mind that people round it off to 1000 but in reality the number is 1024

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Observe and Secure All Apps with Splunk

 Join Us for Our Next Tech Talk: Observe and Secure All Apps with SplunkAs organizations continue to innovate ...

What's New in Splunk Observability - August 2025

What's New We are excited to announce the latest enhancements to Splunk Observability Cloud as well as what is ...

Introduction to Splunk AI

How are you using AI in Splunk? Whether you see AI as a threat or opportunity, AI is here to stay. Lucky for ...