<?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 Extracting one field into multiple fields in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Extracting-one-field-into-multiple-fields/m-p/363468#M107320</link>
    <description>&lt;P&gt;I have some data that looks similar to the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{
  Name: Record1
  Tags: [
    {
      Key: Tag1
      Value: Value1
    }
    {
      Key: Tag2
      Value: Value2
    }
    {
      Key: Tag3
      Value: Value3
    }    
  ]
}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I am trying to create output table that looks like the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Name     Tag1    Tag2    Tag3
-------------------------------
Record1  Value1  Value2  Value3
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What have been trying to do so far is pathing into Tags and them combining them into one value, like so:&lt;/P&gt;

&lt;P&gt;... | spath tags=Tags{} output=Tags | nomv Tags&lt;/P&gt;

&lt;P&gt;This gives me one field with all the values that look like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; {Key:Tag1,Value:Value1}{Key:Tag2,Value:Value2}{Key:Tag3,Value:Value3}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I'm thinking what I need to do next is a foreach statement to extract those values into an eval field, but can't quite seem to get it.  Keep in mind I don't know what the Tags will be actually named, what their value will be, or how many there are for any given record. &lt;/P&gt;

&lt;P&gt;Any suggestions would be appreciated.  Or if there is an easier way to accomplish this, I am open to anything.  &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
    <pubDate>Mon, 19 Mar 2018 13:32:01 GMT</pubDate>
    <dc:creator>BearMormont</dc:creator>
    <dc:date>2018-03-19T13:32:01Z</dc:date>
    <item>
      <title>Extracting one field into multiple fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extracting-one-field-into-multiple-fields/m-p/363468#M107320</link>
      <description>&lt;P&gt;I have some data that looks similar to the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{
  Name: Record1
  Tags: [
    {
      Key: Tag1
      Value: Value1
    }
    {
      Key: Tag2
      Value: Value2
    }
    {
      Key: Tag3
      Value: Value3
    }    
  ]
}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I am trying to create output table that looks like the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Name     Tag1    Tag2    Tag3
-------------------------------
Record1  Value1  Value2  Value3
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What have been trying to do so far is pathing into Tags and them combining them into one value, like so:&lt;/P&gt;

&lt;P&gt;... | spath tags=Tags{} output=Tags | nomv Tags&lt;/P&gt;

&lt;P&gt;This gives me one field with all the values that look like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; {Key:Tag1,Value:Value1}{Key:Tag2,Value:Value2}{Key:Tag3,Value:Value3}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I'm thinking what I need to do next is a foreach statement to extract those values into an eval field, but can't quite seem to get it.  Keep in mind I don't know what the Tags will be actually named, what their value will be, or how many there are for any given record. &lt;/P&gt;

&lt;P&gt;Any suggestions would be appreciated.  Or if there is an easier way to accomplish this, I am open to anything.  &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 19 Mar 2018 13:32:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extracting-one-field-into-multiple-fields/m-p/363468#M107320</guid>
      <dc:creator>BearMormont</dc:creator>
      <dc:date>2018-03-19T13:32:01Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting one field into multiple fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extracting-one-field-into-multiple-fields/m-p/363469#M107321</link>
      <description>&lt;P&gt;Try using transforms and extract keys and values into different groups.&lt;/P&gt;

&lt;P&gt;Enable multi value for the transforms&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;&lt;BR /&gt;
[keyvaluepairs]&lt;BR /&gt;
REGEX = \{\"key\"\:\"([^\"]+)\",\"value\"\:\"([^\"]+)&lt;BR /&gt;
FORMAT=$1::$2&lt;BR /&gt;
&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;and use above transforms like below in search&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;search | extract keyvaluepairs&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Mar 2018 23:14:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extracting-one-field-into-multiple-fields/m-p/363469#M107321</guid>
      <dc:creator>kyaparla</dc:creator>
      <dc:date>2018-03-20T23:14:26Z</dc:date>
    </item>
  </channel>
</rss>

