<?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: How to extract key/values from a string? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-key-values-from-a-string/m-p/238290#M70792</link>
    <description>&lt;P&gt;I would go for the props and transforms option.&lt;/P&gt;

&lt;P&gt;Your transforms.conf can be something as simple as (you might need to improve the regex below by the way):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[mytransform]
REGEX  = \"(?&amp;lt;_KEY_1&amp;gt;\w+)=(?&amp;lt;_VAL_1&amp;gt;\w+)\"
FORMAT = $1::$2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And then in your props.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; [sourcetype BLA]
 ...
 REPORT-abc = mytransform
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/6.3.2/admin/Transformsconf"&gt;http://docs.splunk.com/Documentation/Splunk/6.3.2/admin/Transformsconf&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 19 Jan 2016 12:28:12 GMT</pubDate>
    <dc:creator>javiergn</dc:creator>
    <dc:date>2016-01-19T12:28:12Z</dc:date>
    <item>
      <title>How to extract key/values from a string?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-key-values-from-a-string/m-p/238289#M70791</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;Well, there must be a really easy answer for this, but I seem to be mentally blocked. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;So if I have field after a search that contains a string with regular key/value syntax, but I don't know what keys will be there, how can I extract those keys into actual Splunk fields?&lt;/P&gt;

&lt;P&gt;E.g.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eval bla="gc_bla=bla gc_hsg=1234 gc_foo=bar" | ... 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;How do I get gc_bla, gc_hsg and gc_foo as fields in Splunk that I can work with?&lt;/P&gt;

&lt;P&gt;I figured out how to do it with extract and something in transforms.conf, but I expect there is a more straight forward way?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 08:28:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-key-values-from-a-string/m-p/238289#M70791</guid>
      <dc:creator>knielsen</dc:creator>
      <dc:date>2020-09-29T08:28:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract key/values from a string?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-key-values-from-a-string/m-p/238290#M70792</link>
      <description>&lt;P&gt;I would go for the props and transforms option.&lt;/P&gt;

&lt;P&gt;Your transforms.conf can be something as simple as (you might need to improve the regex below by the way):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[mytransform]
REGEX  = \"(?&amp;lt;_KEY_1&amp;gt;\w+)=(?&amp;lt;_VAL_1&amp;gt;\w+)\"
FORMAT = $1::$2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And then in your props.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; [sourcetype BLA]
 ...
 REPORT-abc = mytransform
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/6.3.2/admin/Transformsconf"&gt;http://docs.splunk.com/Documentation/Splunk/6.3.2/admin/Transformsconf&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jan 2016 12:28:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-key-values-from-a-string/m-p/238290#M70792</guid>
      <dc:creator>javiergn</dc:creator>
      <dc:date>2016-01-19T12:28:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract key/values from a string?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-key-values-from-a-string/m-p/238291#M70793</link>
      <description>&lt;P&gt;hi knielsen &lt;BR /&gt;
Use this search code to extract your field&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    .......|rex field=bla    "\"gc_bla\=(?&amp;lt;field1&amp;gt;[\w+]+)\s+gc_hsg\=(?&amp;lt;field2&amp;gt;[\d+]+)\s+gc_foo=(?&amp;lt;field3&amp;gt;[\d+]+)\""|table field1 field2 field3
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You can use this regex in you transform.conf file &lt;/P&gt;</description>
      <pubDate>Tue, 19 Jan 2016 12:57:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-key-values-from-a-string/m-p/238291#M70793</guid>
      <dc:creator>chimell</dc:creator>
      <dc:date>2016-01-19T12:57:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract key/values from a string?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-key-values-from-a-string/m-p/238292#M70794</link>
      <description>&lt;P&gt;That's almost exactly what I came up with already, but thinking that using transforms.conf would be overkill. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; The key=value structure in the string is so simple that I was thinking there must be a way to this without this kind of configuration.&lt;/P&gt;

&lt;P&gt;If there is no more generic way, I'll accept this later.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jan 2016 13:03:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-key-values-from-a-string/m-p/238292#M70794</guid>
      <dc:creator>knielsen</dc:creator>
      <dc:date>2016-01-19T13:03:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract key/values from a string?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-key-values-from-a-string/m-p/238293#M70795</link>
      <description>&lt;P&gt;I cannot use this kind of regex because "&lt;EM&gt;I don't know what keys will be there&lt;/EM&gt;". Also, I cannot be sure of the order. Otherwise that would be the way to go.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jan 2016 13:05:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-key-values-from-a-string/m-p/238293#M70795</guid>
      <dc:creator>knielsen</dc:creator>
      <dc:date>2016-01-19T13:05:32Z</dc:date>
    </item>
  </channel>
</rss>

