<?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 Field extraction with kv/extract in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Field-extraction-with-kv-extract/m-p/11483#M786</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I am trying to extract fields of the form &lt;CODE&gt;[key1=value with spaces] [key2=value with spaces]&lt;/CODE&gt; using the kv search command, as demonstrated on &lt;A href="http://blogs.splunk.com/2008/02/12/delimiter-based-key-value-pair-extraction/" rel="nofollow"&gt;http://blogs.splunk.com/2008/02/12/delimiter-based-key-value-pair-extraction/&lt;/A&gt;.&lt;/P&gt;

&lt;P&gt;I am using the search command:&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
  &lt;P&gt;... | kv pairdelim="[]" kvdelim="="&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;This doesn't seem to work as expected; I get instead extracted fields such as &lt;CODE&gt;key1=value&lt;/CODE&gt; &lt;CODE&gt;key2=value&lt;/CODE&gt; instead of what I was expecting, &lt;CODE&gt;key1=value with spaces&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;Any help would be appreciated.&lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
    <pubDate>Wed, 14 Apr 2010 21:10:33 GMT</pubDate>
    <dc:creator>davidha</dc:creator>
    <dc:date>2010-04-14T21:10:33Z</dc:date>
    <item>
      <title>Field extraction with kv/extract</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Field-extraction-with-kv-extract/m-p/11483#M786</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I am trying to extract fields of the form &lt;CODE&gt;[key1=value with spaces] [key2=value with spaces]&lt;/CODE&gt; using the kv search command, as demonstrated on &lt;A href="http://blogs.splunk.com/2008/02/12/delimiter-based-key-value-pair-extraction/" rel="nofollow"&gt;http://blogs.splunk.com/2008/02/12/delimiter-based-key-value-pair-extraction/&lt;/A&gt;.&lt;/P&gt;

&lt;P&gt;I am using the search command:&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
  &lt;P&gt;... | kv pairdelim="[]" kvdelim="="&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;This doesn't seem to work as expected; I get instead extracted fields such as &lt;CODE&gt;key1=value&lt;/CODE&gt; &lt;CODE&gt;key2=value&lt;/CODE&gt; instead of what I was expecting, &lt;CODE&gt;key1=value with spaces&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;Any help would be appreciated.&lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 14 Apr 2010 21:10:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Field-extraction-with-kv-extract/m-p/11483#M786</guid>
      <dc:creator>davidha</dc:creator>
      <dc:date>2010-04-14T21:10:33Z</dc:date>
    </item>
    <item>
      <title>Re: Field extraction with kv/extract</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Field-extraction-with-kv-extract/m-p/11484#M787</link>
      <description>&lt;P&gt;Can you post some sample data that you are trying to extract the values out of?&lt;/P&gt;</description>
      <pubDate>Wed, 14 Apr 2010 21:16:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Field-extraction-with-kv-extract/m-p/11484#M787</guid>
      <dc:creator>ftk</dc:creator>
      <dc:date>2010-04-14T21:16:54Z</dc:date>
    </item>
    <item>
      <title>Re: Field extraction with kv/extract</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Field-extraction-with-kv-extract/m-p/11485#M788</link>
      <description>&lt;P&gt;I don't think your example is "delimiter based" exactly.&lt;/P&gt;

&lt;P&gt;I think the best approach for this would be to add a &lt;CODE&gt;transforms.conf&lt;/CODE&gt; entry for this.  (You can often add regex-based extractions more quickly using &lt;CODE&gt;EXTRACT-&lt;/CODE&gt; as of Splunk 4.0+, but unfortunately this is one case where you have to do make a full-blown &lt;CODE&gt;transforms.conf&lt;/CODE&gt; stanza because we need repeating matches, which &lt;CODE&gt;EXTRACT&lt;/CODE&gt; doesn't support.)  Also, the &lt;CODE&gt;rex&lt;/CODE&gt; search command does not work because you are extracting both the field name and the field value; so using a &lt;CODE&gt;transforms&lt;/CODE&gt; entry is really your best option.&lt;/P&gt;

&lt;P&gt;Something like this should do the trick:&lt;/P&gt;

&lt;PRE&gt;
[my_kv_pairs_with_spaces]
REGEX = \[([^=]*)=([^\]]*)\]
FORMAT = $1::$2
MV_ADD = true
&lt;/PRE&gt;

&lt;P&gt;Then make sure your add an entry in your &lt;CODE&gt;props.conf&lt;/CODE&gt; file that points to your transformer.  For example:&lt;/P&gt;

&lt;PRE&gt;
[my_sourcetype]
REPORTS-my_fields = my_kv_pairs_with_spaces
&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;Note:&lt;/STRONG&gt;  I'm assuming since you trying to use the &lt;CODE&gt;kv&lt;/CODE&gt; command that splunk isn't just extracting these correctly out of the box for you.  If you haven't tried letting Splunk do the extractions automatically, I would definitely start there.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Apr 2010 21:29:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Field-extraction-with-kv-extract/m-p/11485#M788</guid>
      <dc:creator>Lowell</dc:creator>
      <dc:date>2010-04-14T21:29:23Z</dc:date>
    </item>
    <item>
      <title>Re: Field extraction with kv/extract</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Field-extraction-with-kv-extract/m-p/11486#M789</link>
      <description>&lt;P&gt;Thanks, that worked a treat. Yeah, Splunk wasn't automatically extracting fields of that form.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Apr 2010 16:28:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Field-extraction-with-kv-extract/m-p/11486#M789</guid>
      <dc:creator>davidha</dc:creator>
      <dc:date>2010-04-21T16:28:38Z</dc:date>
    </item>
  </channel>
</rss>

