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!

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 ...