<?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: Bitfield lookup in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Bitfield-lookup/m-p/161704#M45700</link>
    <description>&lt;P&gt;I'm not sure to understand,&lt;BR /&gt;
I've tried &lt;BR /&gt;
|stats count | eval bitfield=3 | eval numfield=log(bitfield,2)+1&lt;/P&gt;

&lt;P&gt;and I get numfield=2.58&lt;/P&gt;

&lt;P&gt;I would need something like numfield=(1;2)..&lt;/P&gt;</description>
    <pubDate>Mon, 02 Dec 2013 13:38:57 GMT</pubDate>
    <dc:creator>sbsbb</dc:creator>
    <dc:date>2013-12-02T13:38:57Z</dc:date>
    <item>
      <title>Bitfield lookup</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Bitfield-lookup/m-p/161702#M45698</link>
      <description>&lt;P&gt;I have a field in the logs, that is a Bit-field.&lt;BR /&gt;
Is there a way, a function to translate those field in a human readable mvfield ?&lt;/P&gt;

&lt;P&gt;Here is a bitfield translation example :&lt;BR /&gt;
1 test1&lt;BR /&gt;
2 test2&lt;BR /&gt;
4 test3&lt;BR /&gt;
8 test4&lt;/P&gt;

&lt;P&gt;What I would like, is a way to translate "3" in "test1,test2)&lt;/P&gt;

&lt;P&gt;I would enjoy a | bitlookup bittranslation.csv  bitfield &lt;BR /&gt;
But I guess I would have seen it already, if there were one &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 02 Dec 2013 10:15:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Bitfield-lookup/m-p/161702#M45698</guid>
      <dc:creator>sbsbb</dc:creator>
      <dc:date>2013-12-02T10:15:51Z</dc:date>
    </item>
    <item>
      <title>Re: Bitfield lookup</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Bitfield-lookup/m-p/161703#M45699</link>
      <description>&lt;P&gt;Use MATH&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;bitfield = 2^(x-1)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;(because your first bitfield is not 0 but 1, hence the x-1 instead of x)&lt;BR /&gt;
So,&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;x-1 = log2(bitfield)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And finally&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;x = log2(bitfield)+1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So when bitfield is 8, log2(bitfield) is 3, and so x = 3+1 = 4.&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;eval&lt;/CODE&gt; has the &lt;CODE&gt;log(number,base)&lt;/CODE&gt; function that you can use for doing this.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eval numfield=log(bitfield,2)+1
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 02 Dec 2013 10:42:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Bitfield-lookup/m-p/161703#M45699</guid>
      <dc:creator>Ayn</dc:creator>
      <dc:date>2013-12-02T10:42:31Z</dc:date>
    </item>
    <item>
      <title>Re: Bitfield lookup</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Bitfield-lookup/m-p/161704#M45700</link>
      <description>&lt;P&gt;I'm not sure to understand,&lt;BR /&gt;
I've tried &lt;BR /&gt;
|stats count | eval bitfield=3 | eval numfield=log(bitfield,2)+1&lt;/P&gt;

&lt;P&gt;and I get numfield=2.58&lt;/P&gt;

&lt;P&gt;I would need something like numfield=(1;2)..&lt;/P&gt;</description>
      <pubDate>Mon, 02 Dec 2013 13:38:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Bitfield-lookup/m-p/161704#M45700</guid>
      <dc:creator>sbsbb</dc:creator>
      <dc:date>2013-12-02T13:38:57Z</dc:date>
    </item>
    <item>
      <title>Re: Bitfield lookup</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Bitfield-lookup/m-p/161705#M45701</link>
      <description>&lt;P&gt;Well my understanding of the bitfield is that it would always be a 2 exponent? So it'd follow the pattern 1,2,4,8,16,32,...&lt;/P&gt;

&lt;P&gt;In that case bitfield will never be 3.&lt;/P&gt;</description>
      <pubDate>Mon, 02 Dec 2013 13:48:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Bitfield-lookup/m-p/161705#M45701</guid>
      <dc:creator>Ayn</dc:creator>
      <dc:date>2013-12-02T13:48:04Z</dc:date>
    </item>
    <item>
      <title>Re: Bitfield lookup</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Bitfield-lookup/m-p/161706#M45702</link>
      <description>&lt;P&gt;If I have a bit field set to 3, that means that I have the bit 1 and 2 set. That why I need a function to check what bits are set&lt;/P&gt;</description>
      <pubDate>Mon, 02 Dec 2013 17:13:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Bitfield-lookup/m-p/161706#M45702</guid>
      <dc:creator>sbsbb</dc:creator>
      <dc:date>2013-12-02T17:13:00Z</dc:date>
    </item>
    <item>
      <title>Re: Bitfield lookup</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Bitfield-lookup/m-p/161707#M45703</link>
      <description>&lt;P&gt;Extract using math:&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;divide by 2^n to shift the value right by n bits&lt;/LI&gt;
&lt;LI&gt;modulo by 2 to get the low bit&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;|stats count | eval bitfield = 5 | eval numfield1=(bitfield % 2) | eval numfield2 = floor(bitfield / 2) % 2 | eval numfield3 = floor(bitfield / 4) % 2&lt;/P&gt;

&lt;P&gt;or...&lt;/P&gt;

&lt;P&gt;Extracting with a CSV:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|stats count | eval bitfield = 5 | lookup bitlookup.csv bitfield OUTPUT bitnames | makemv delim="|" bitnames

$ cat bitlookup.csv

bitfield,bitnames
0,b0
1,b1
2,b2
3,b1|b2
4,b4
5,b1|b4
6,b2|b4
7,b1|b2|b4
8,b8
9,b1|b8
10,b2|b8
11,b1|b2|b8
12,b4|b8
13,b1|b4|b8
14,b2|b4|b8
15,b1|b2|b4|b8
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 02 Dec 2013 21:27:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Bitfield-lookup/m-p/161707#M45703</guid>
      <dc:creator>sciurus</dc:creator>
      <dc:date>2013-12-02T21:27:17Z</dc:date>
    </item>
  </channel>
</rss>

