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
Get Updates on the Splunk Community!

Accelerating Observability as Code with the Splunk AI Assistant

We’ve seen in previous posts what Observability as Code (OaC) is and how it’s now essential for managing ...

Integrating Splunk Search API and Quarto to Create Reproducible Investigation ...

 Splunk is More Than Just the Web Console For Digital Forensics and Incident Response (DFIR) practitioners, ...

Congratulations to the 2025-2026 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...