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!

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...

New This Month - Observability Updates Give Extended Visibility and Improve User ...

This month is a collection of special news! From Magic Quadrant updates to AppDynamics integrations to ...

Intro to Splunk Synthetic Monitoring

In our last post, we mentioned that the 3 key pieces of observability – metrics, logs, and traces – provide ...