<?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: Converting units in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Converting-units-in-my-classification-breaks-my-alert/m-p/629604#M218720</link>
    <description>&lt;P&gt;&lt;SPAN&gt;This could be also solution for you.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.splunk.com/t5/Splunk-Search/FileSize-to-human-readable/m-p/629602/highlight/true#M218718" target="_blank" rel="noopener"&gt;https://community.splunk.com/t5/Splunk-Search/FileSize-to-human-readable/m-p/629602/highlight/true#M218718&lt;/A&gt;&lt;/P&gt;&lt;PRE&gt;| makeresults count=35&lt;BR /&gt;```THIS SECTION IS JUST CREATING SAMPLE VALUES.```&lt;BR /&gt;| streamstats count as digit&lt;BR /&gt;| eval val=pow(10,digit-1), val=val+random()%val&lt;BR /&gt;| foreach bytes [eval &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;=val]&lt;BR /&gt;| table digit val bytes&lt;BR /&gt;| fieldformat val=tostring(val,"commas")&lt;BR /&gt;&lt;BR /&gt;```THE FOLLOWING LINES MAY BE WHAT ACHIEVES THE FORMAT YOU ARE LOOKING FOR.```&lt;BR /&gt;| fieldformat bytes=printf("% 10s",printf("%.2f",round(bytes/pow(1024,if(bytes=0,0,floor(min(log(bytes,1024),10)))),2)).case(bytes=0 OR log(bytes,1024)&amp;lt;1,"B ", log(bytes,1024)&amp;lt;2,"KiB", log(bytes,1024)&amp;lt;3,"MiB", log(bytes,1024)&amp;lt;4,"GiB", log(bytes,1024)&amp;lt;5,"TiB", log(bytes,1024)&amp;lt;6,"PiB", log(bytes,1024)&amp;lt;7,"EiB", log(bytes,1024)&amp;lt;8,"ZiB", log(bytes,1024)&amp;lt;9,"YiB", log(bytes,1024)&amp;lt;10,"RiB", log(bytes,1024)&amp;lt;11,"QiB", 1=1, "QiB"))&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you can install app or ask admin on your to install app,&lt;/P&gt;&lt;P&gt;installing&amp;nbsp;add-on&amp;nbsp;&lt;A title="Numeral system macros for Splunk" href="https://splunkbase.splunk.com/app/6595" target="_blank" rel="nofollow noopener noreferrer"&gt;Numeral system macros for Splunk&lt;/A&gt;&amp;nbsp;enables you to&lt;SPAN&gt;&amp;nbsp;use macros numeral_binary_symbol(1) or numeral_binary_symbol(2).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Example&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;| makeresults count=35&lt;BR /&gt;```THIS SECTION IS JUST CREATING SAMPLE VALUES.```&lt;BR /&gt;| streamstats count as digit&lt;BR /&gt;| eval val=pow(10,digit-1), val=val+random()%val&lt;BR /&gt;| foreach bytes [eval &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;=val]&lt;BR /&gt;| table digit val bytes&lt;BR /&gt;| fieldformat val=tostring(val,"commas")&lt;BR /&gt;&lt;BR /&gt;```THE FOLLOWING LINES MAY BE WHAT ACHIEVES THE FORMAT YOU ARE LOOKING FOR.```&lt;BR /&gt;| fieldformat bytes=printf("% 10s",`numeral_binary_symbol(bytes,2)`)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Numeral system macros for Splunk&lt;/P&gt;&lt;P&gt;&lt;A href="https://splunkbase.splunk.com/app/6595" target="_blank" rel="noopener nofollow noreferrer"&gt;https://splunkbase.splunk.com/app/6595&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Usage:&lt;/P&gt;&lt;P&gt;How to convert a large number to string with expressions of long and short scales, or neither.&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.splunk.com/t5/Splunk-Search/How-to-convert-a-large-number-to-string-with-expressio" target="_blank" rel="noopener"&gt;https://community.splunk.com/t5/Splunk-Search/How-to-convert-a-large-number-to-string-with-expressio&lt;/A&gt;...&lt;/P&gt;</description>
    <pubDate>Sat, 04 Feb 2023 12:13:34 GMT</pubDate>
    <dc:creator>tfujita_splunk</dc:creator>
    <dc:date>2023-02-04T12:13:34Z</dc:date>
    <item>
      <title>Converting units in my classification breaks my alert?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Converting-units-in-my-classification-breaks-my-alert/m-p/530070#M149760</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I had a good base search for a calculation and alerting when an upload/download happens, but now I tried to tidy it up and convert bytes to KB and show a percentage as a "10%" instead of just "10", but somewhere along the way my search breaks...&amp;nbsp;&lt;BR /&gt;When i try to show bytes as KB using this:&lt;/P&gt;
&lt;P&gt;| eval total_KB_bytes=round(total_bytes/1024,0)."KB"&lt;BR /&gt;| eval KB_bytes_in=round(bytes_in/1024,0)."KB"&lt;BR /&gt;| eval KB_bytes_out=round(bytes_out/1024,0)."KB"&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;my Classification and&amp;nbsp; Alert break.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Any help would be greatly appreciated!&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;The&amp;nbsp;The original search is:&lt;/P&gt;
&lt;DIV&gt;
&lt;DIV&gt;
&lt;DIV&gt;
&lt;DIV&gt;
&lt;DIV&gt;
&lt;DIV&gt;
&lt;PRE&gt;index=zscaler http_method IN ("POST", "PUT")

| rename bytes as "total_bytes"
| table _time index user src_user_email dest app appclass category http_method filetype total_bytes bytes_in bytes_out

| eval user_bytes_perc_download = round((bytes_in/total_bytes)*100,2)
| eval user_bytes_perc_upload = round((bytes_out/total_bytes)*100,2)
| eval Classification=case(user_bytes_perc_download &amp;gt; 70,"download", user_bytes_perc_upload &amp;gt; 70,"upload", user_bytes_perc_download &amp;lt;70 AND user_bytes_perc_upload &amp;lt;70, "none")

| eval Alert=if((Classification="download" OR Classification="upload") AND total_bytes &amp;gt; 20000, "YES", "NO")&lt;/PRE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Sun, 05 Feb 2023 23:18:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Converting-units-in-my-classification-breaks-my-alert/m-p/530070#M149760</guid>
      <dc:creator>klaudiac</dc:creator>
      <dc:date>2023-02-05T23:18:19Z</dc:date>
    </item>
    <item>
      <title>Re: Converting units</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Converting-units-in-my-classification-breaks-my-alert/m-p/530073#M149763</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/223748"&gt;@klaudiac&lt;/a&gt;,&lt;BR /&gt;&lt;BR /&gt;Try &lt;EM&gt;fieldformat&lt;/EM&gt;. It does change the way a value is displayed, but does not change the underlaying value/type of data.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;|  eval kb=bytes/1024
| fieldformat kb=round(kb,2)."kb"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;BR /&gt;Hope it helps.&lt;BR /&gt;BR&lt;BR /&gt;Ralph&lt;/P&gt;</description>
      <pubDate>Thu, 19 Nov 2020 12:21:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Converting-units-in-my-classification-breaks-my-alert/m-p/530073#M149763</guid>
      <dc:creator>rnowitzki</dc:creator>
      <dc:date>2020-11-19T12:21:24Z</dc:date>
    </item>
    <item>
      <title>Re: Converting units</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Converting-units-in-my-classification-breaks-my-alert/m-p/530085#M149769</link>
      <description>&lt;P&gt;Hi Ralph,&amp;nbsp;&lt;/P&gt;&lt;P&gt;The | fieldformat makes it look so much neater, thanks very much! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Nov 2020 14:01:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Converting-units-in-my-classification-breaks-my-alert/m-p/530085#M149769</guid>
      <dc:creator>klaudiac</dc:creator>
      <dc:date>2020-11-19T14:01:01Z</dc:date>
    </item>
    <item>
      <title>Re: Converting units</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Converting-units-in-my-classification-breaks-my-alert/m-p/530087#M149771</link>
      <description>&lt;P&gt;Hi Klaudia,&lt;BR /&gt;&lt;BR /&gt;There is nothing wrong with your SPL &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp; And you found a workaround (Set the Alert trigger before adding the "KB"), so this is just cosmetic:&lt;BR /&gt;&lt;BR /&gt;You could just change the last 5 evals to fieldformat.&amp;nbsp;&lt;BR /&gt;That way, the values are still numbers, but display for us silly humans with "KB" (or %)&amp;nbsp; &lt;span class="lia-unicode-emoji" title=":face_with_tongue:"&gt;😛&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval total_KB_bytes=total_KB_bytes."KB"
change to =&amp;gt; | fieldformat total_KB_bytes=total_KB_bytes."KB"

| eval KB_bytes_in=KB_bytes_in."KB"
change to =&amp;gt; | fieldformat KB_bytes_in=KB_bytes_in."KB"&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;and so forth with all 5 evals.&lt;BR /&gt;&lt;BR /&gt;Now you can still calculate/compare/whatever with the values, regardless of the "KB" added.&lt;BR /&gt;&lt;BR /&gt;Cheers&lt;BR /&gt;Ralph&lt;/P&gt;</description>
      <pubDate>Thu, 19 Nov 2020 13:57:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Converting-units-in-my-classification-breaks-my-alert/m-p/530087#M149771</guid>
      <dc:creator>rnowitzki</dc:creator>
      <dc:date>2020-11-19T13:57:05Z</dc:date>
    </item>
    <item>
      <title>Re: Converting units</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Converting-units-in-my-classification-breaks-my-alert/m-p/629604#M218720</link>
      <description>&lt;P&gt;&lt;SPAN&gt;This could be also solution for you.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.splunk.com/t5/Splunk-Search/FileSize-to-human-readable/m-p/629602/highlight/true#M218718" target="_blank" rel="noopener"&gt;https://community.splunk.com/t5/Splunk-Search/FileSize-to-human-readable/m-p/629602/highlight/true#M218718&lt;/A&gt;&lt;/P&gt;&lt;PRE&gt;| makeresults count=35&lt;BR /&gt;```THIS SECTION IS JUST CREATING SAMPLE VALUES.```&lt;BR /&gt;| streamstats count as digit&lt;BR /&gt;| eval val=pow(10,digit-1), val=val+random()%val&lt;BR /&gt;| foreach bytes [eval &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;=val]&lt;BR /&gt;| table digit val bytes&lt;BR /&gt;| fieldformat val=tostring(val,"commas")&lt;BR /&gt;&lt;BR /&gt;```THE FOLLOWING LINES MAY BE WHAT ACHIEVES THE FORMAT YOU ARE LOOKING FOR.```&lt;BR /&gt;| fieldformat bytes=printf("% 10s",printf("%.2f",round(bytes/pow(1024,if(bytes=0,0,floor(min(log(bytes,1024),10)))),2)).case(bytes=0 OR log(bytes,1024)&amp;lt;1,"B ", log(bytes,1024)&amp;lt;2,"KiB", log(bytes,1024)&amp;lt;3,"MiB", log(bytes,1024)&amp;lt;4,"GiB", log(bytes,1024)&amp;lt;5,"TiB", log(bytes,1024)&amp;lt;6,"PiB", log(bytes,1024)&amp;lt;7,"EiB", log(bytes,1024)&amp;lt;8,"ZiB", log(bytes,1024)&amp;lt;9,"YiB", log(bytes,1024)&amp;lt;10,"RiB", log(bytes,1024)&amp;lt;11,"QiB", 1=1, "QiB"))&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you can install app or ask admin on your to install app,&lt;/P&gt;&lt;P&gt;installing&amp;nbsp;add-on&amp;nbsp;&lt;A title="Numeral system macros for Splunk" href="https://splunkbase.splunk.com/app/6595" target="_blank" rel="nofollow noopener noreferrer"&gt;Numeral system macros for Splunk&lt;/A&gt;&amp;nbsp;enables you to&lt;SPAN&gt;&amp;nbsp;use macros numeral_binary_symbol(1) or numeral_binary_symbol(2).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Example&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;| makeresults count=35&lt;BR /&gt;```THIS SECTION IS JUST CREATING SAMPLE VALUES.```&lt;BR /&gt;| streamstats count as digit&lt;BR /&gt;| eval val=pow(10,digit-1), val=val+random()%val&lt;BR /&gt;| foreach bytes [eval &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;=val]&lt;BR /&gt;| table digit val bytes&lt;BR /&gt;| fieldformat val=tostring(val,"commas")&lt;BR /&gt;&lt;BR /&gt;```THE FOLLOWING LINES MAY BE WHAT ACHIEVES THE FORMAT YOU ARE LOOKING FOR.```&lt;BR /&gt;| fieldformat bytes=printf("% 10s",`numeral_binary_symbol(bytes,2)`)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Numeral system macros for Splunk&lt;/P&gt;&lt;P&gt;&lt;A href="https://splunkbase.splunk.com/app/6595" target="_blank" rel="noopener nofollow noreferrer"&gt;https://splunkbase.splunk.com/app/6595&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Usage:&lt;/P&gt;&lt;P&gt;How to convert a large number to string with expressions of long and short scales, or neither.&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.splunk.com/t5/Splunk-Search/How-to-convert-a-large-number-to-string-with-expressio" target="_blank" rel="noopener"&gt;https://community.splunk.com/t5/Splunk-Search/How-to-convert-a-large-number-to-string-with-expressio&lt;/A&gt;...&lt;/P&gt;</description>
      <pubDate>Sat, 04 Feb 2023 12:13:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Converting-units-in-my-classification-breaks-my-alert/m-p/629604#M218720</guid>
      <dc:creator>tfujita_splunk</dc:creator>
      <dc:date>2023-02-04T12:13:34Z</dc:date>
    </item>
  </channel>
</rss>

