<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: convert bytes to megabytes in report in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/convert-bytes-to-megabytes-in-report/m-p/17311#M2420</link>
    <description>&lt;P&gt;on 4.x you should also be able to put it all into the "timechart" command:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | timechart eval(sum(bytes)/1024/1024) as totMBs
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 14 Jul 2010 03:31:51 GMT</pubDate>
    <dc:creator>Paolo_Prigione</dc:creator>
    <dc:date>2010-07-14T03:31:51Z</dc:date>
    <item>
      <title>convert bytes to megabytes in report</title>
      <link>https://community.splunk.com/t5/Splunk-Search/convert-bytes-to-megabytes-in-report/m-p/17308#M2417</link>
      <description>&lt;P&gt;Hello.&lt;/P&gt;

&lt;P&gt;I'm building a report with the following query:&lt;/P&gt;

&lt;P&gt;sourcetype="access_combined" dmanager | timechart sum(bytes)&lt;/P&gt;

&lt;P&gt;Which works, but I want to convert the bytes to megs. I tried sum(bytes/1024) but got an error when I tried this.&lt;/P&gt;

&lt;P&gt;Any help is much appreciated.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jul 2010 22:24:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/convert-bytes-to-megabytes-in-report/m-p/17308#M2417</guid>
      <dc:creator>jxjackso</dc:creator>
      <dc:date>2010-07-13T22:24:24Z</dc:date>
    </item>
    <item>
      <title>Re: convert bytes to megabytes in report</title>
      <link>https://community.splunk.com/t5/Splunk-Search/convert-bytes-to-megabytes-in-report/m-p/17309#M2418</link>
      <description>&lt;P&gt;You can use the eval command to make changes to values:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="access_combined" dmanager | eval megabytes=((bytes/1024)/1024) | timechart sum(megabytes)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This will also work without the parenthesis:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eval megabytes=bytes/1024/1024 | 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;For more detail:&lt;/P&gt;

&lt;P&gt;&lt;A href="http://www.splunk.com/base/Documentation/latest/SearchReference/Eval" rel="nofollow"&gt;http://www.splunk.com/base/Documentation/latest/SearchReference/Eval&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jul 2010 22:46:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/convert-bytes-to-megabytes-in-report/m-p/17309#M2418</guid>
      <dc:creator>Simeon</dc:creator>
      <dc:date>2010-07-13T22:46:01Z</dc:date>
    </item>
    <item>
      <title>Re: convert bytes to megabytes in report</title>
      <link>https://community.splunk.com/t5/Splunk-Search/convert-bytes-to-megabytes-in-report/m-p/17310#M2419</link>
      <description>&lt;P&gt;Here is a little search macro that does a little more than just converting a value to megabytes - it formats the value depending on its size in GB, MB, KB or bytes. Not usable for chart, but when displaying top-lists it comes quite handy.&lt;/P&gt;

&lt;P&gt;The definition looks like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;if($bytes$&amp;gt;1073741824, tostring(round($bytes$/1073741824,2))+" GB", if($bytes$&amp;gt;1048576, tostring(round($bytes$/1048576,2))+" MB", if($bytes$&amp;gt;1024, tostring(round($bytes$/1024))+" KB", tostring($bytes$)+" Bytes")))
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;with the argument &lt;CODE&gt;bytes&lt;/CODE&gt; and can be used like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=access_combined | stats sum(bytes) as volume by uri | sort -volume | head 10 | eval volume=`format_bytes(volume)`
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;which would print out smth like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;              uri                       volume
------------------------------------- ---------
/url1                                  1.54 GB
/url2                                  656.34 MB
/url3                                  474.46 MB
/url4                                  291.72 MB
/url1                                  62.84 MB
/url1                                  26.08 MB
...                                     
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 14 Jul 2010 03:16:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/convert-bytes-to-megabytes-in-report/m-p/17310#M2419</guid>
      <dc:creator>ziegfried</dc:creator>
      <dc:date>2010-07-14T03:16:02Z</dc:date>
    </item>
    <item>
      <title>Re: convert bytes to megabytes in report</title>
      <link>https://community.splunk.com/t5/Splunk-Search/convert-bytes-to-megabytes-in-report/m-p/17311#M2420</link>
      <description>&lt;P&gt;on 4.x you should also be able to put it all into the "timechart" command:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | timechart eval(sum(bytes)/1024/1024) as totMBs
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 14 Jul 2010 03:31:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/convert-bytes-to-megabytes-in-report/m-p/17311#M2420</guid>
      <dc:creator>Paolo_Prigione</dc:creator>
      <dc:date>2010-07-14T03:31:51Z</dc:date>
    </item>
    <item>
      <title>Re: convert bytes to megabytes in report</title>
      <link>https://community.splunk.com/t5/Splunk-Search/convert-bytes-to-megabytes-in-report/m-p/17312#M2421</link>
      <description>&lt;P&gt;Any workaround for displaying the numbers in the above format in charts?&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jun 2013 13:28:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/convert-bytes-to-megabytes-in-report/m-p/17312#M2421</guid>
      <dc:creator>RohiniJindam</dc:creator>
      <dc:date>2013-06-27T13:28:14Z</dc:date>
    </item>
    <item>
      <title>Re: convert bytes to megabytes in report</title>
      <link>https://community.splunk.com/t5/Splunk-Search/convert-bytes-to-megabytes-in-report/m-p/17313#M2422</link>
      <description>&lt;P&gt;How does one go about setting this up as a search macro? Looking for some step by step directions.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Sep 2013 13:17:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/convert-bytes-to-megabytes-in-report/m-p/17313#M2422</guid>
      <dc:creator>tb5821</dc:creator>
      <dc:date>2013-09-17T13:17:24Z</dc:date>
    </item>
    <item>
      <title>Re: convert bytes to megabytes in report</title>
      <link>https://community.splunk.com/t5/Splunk-Search/convert-bytes-to-megabytes-in-report/m-p/17314#M2423</link>
      <description>&lt;P&gt;In the example above, the macro is called in the search as "format_bytes", with one argument. This means that the stanza in macros.conf (or Manager -&amp;gt; Advanced Search -&amp;gt; Search macros) as format_bytes(1). The text of the macro is the first one with all of the math. The argument (as identified by the term that keeps repeating as $bytes$) is bytes. The $ $ surrounding it in the macro definition mean "place the text of the argument here."&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 14:47:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/convert-bytes-to-megabytes-in-report/m-p/17314#M2423</guid>
      <dc:creator>sowings</dc:creator>
      <dc:date>2020-09-28T14:47:28Z</dc:date>
    </item>
  </channel>
</rss>

