<?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: Create multivalue field from single number in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Create-multivalue-field-from-single-number/m-p/144112#M40092</link>
    <description>&lt;P&gt;First, I would make the table a bit easier to use - it's only 7 values (15 for hex) and it saves a lot of computational work that is not easy in Splunk:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;code, attr
7,"read, write, execute"
6,"read, write"
5,"read, execute"
4,read
3,"write, execute"
2,write
1,execute
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;yoursearchhere
| eval file_access_user_code= substr(file_access_string, 1, 1)
| eval file_access_group_code= substr(file_access_string, 2, 1)
| eval file_access_world_code= substr(file_access_string, 3, 1)
| lookup file_access_lookup code as file_access_user_code OUTPUT attr as file_access_user
| lookup file_access_lookup code as file_access_group_code OUTPUT attr as file_access_group
| lookup file_access_lookup code as file_access_world_code OUTPUT attr as file_access_world
| makemv delim="," file_access_user
| makemv delim="," file_access_group
| makemv delim="," file_access_world
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;How to do this automatically: you could make &lt;CODE&gt;file_access_user_code&lt;/CODE&gt;, &lt;CODE&gt;file_access_group_code&lt;/CODE&gt; and &lt;CODE&gt;file_access_world_code&lt;/CODE&gt; into calculated fields, and then use them for the automatic lookup. However, your resulting fields will be strings, not multi-valued fields.&lt;/P&gt;</description>
    <pubDate>Fri, 05 Dec 2014 21:15:35 GMT</pubDate>
    <dc:creator>lguinn2</dc:creator>
    <dc:date>2014-12-05T21:15:35Z</dc:date>
    <item>
      <title>Create multivalue field from single number</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Create-multivalue-field-from-single-number/m-p/144111#M40091</link>
      <description>&lt;P&gt;For a simple example of the concept, let's consider Linux file permissions encoding of read, write and execute into a single number:&lt;BR /&gt;
Example: "7, 5, 1"&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;file_access_user_code="7", 
file_access_group_code="5",
file_access_world_code="1" 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If we look at the first number, it says that the user can read (4), write (2), and execute (1): 4+2+1=7&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;code, attr
4, read
2, write
1, execute
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So my field, file_access_user, is a multi-value field equal to (read, write, execute).  Group is read and execute, and world is only execute.&lt;BR /&gt;
My goal is for splunk to see file_access_user_code and extract the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;file_access_user="read, write, execute", 
file_access_group="read, execute",
file_access_world="execute"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I give the chmod example as a simple representation of a much more complex table based on hexadecimal encoding of attributes into a single number.  How can we tell splunk to take a lookup table with columns "code" and "description" and auto-lookup the numeric values to give multi-value fields with all encoded values listed explicitly?&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 18:19:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Create-multivalue-field-from-single-number/m-p/144111#M40091</guid>
      <dc:creator>landen99</dc:creator>
      <dc:date>2020-09-28T18:19:36Z</dc:date>
    </item>
    <item>
      <title>Re: Create multivalue field from single number</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Create-multivalue-field-from-single-number/m-p/144112#M40092</link>
      <description>&lt;P&gt;First, I would make the table a bit easier to use - it's only 7 values (15 for hex) and it saves a lot of computational work that is not easy in Splunk:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;code, attr
7,"read, write, execute"
6,"read, write"
5,"read, execute"
4,read
3,"write, execute"
2,write
1,execute
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;yoursearchhere
| eval file_access_user_code= substr(file_access_string, 1, 1)
| eval file_access_group_code= substr(file_access_string, 2, 1)
| eval file_access_world_code= substr(file_access_string, 3, 1)
| lookup file_access_lookup code as file_access_user_code OUTPUT attr as file_access_user
| lookup file_access_lookup code as file_access_group_code OUTPUT attr as file_access_group
| lookup file_access_lookup code as file_access_world_code OUTPUT attr as file_access_world
| makemv delim="," file_access_user
| makemv delim="," file_access_group
| makemv delim="," file_access_world
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;How to do this automatically: you could make &lt;CODE&gt;file_access_user_code&lt;/CODE&gt;, &lt;CODE&gt;file_access_group_code&lt;/CODE&gt; and &lt;CODE&gt;file_access_world_code&lt;/CODE&gt; into calculated fields, and then use them for the automatic lookup. However, your resulting fields will be strings, not multi-valued fields.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Dec 2014 21:15:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Create-multivalue-field-from-single-number/m-p/144112#M40092</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2014-12-05T21:15:35Z</dc:date>
    </item>
  </channel>
</rss>

