<?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: Extract and Transform Custom Event in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Extract-and-Transform-Custom-Event/m-p/353236#M64696</link>
    <description>&lt;P&gt;Here's a regex that should work for you:&lt;BR /&gt;
&lt;CODE&gt;\[(?&amp;lt;Thread&amp;gt;.*?)\]\s(?&amp;lt;TimeStamp&amp;gt;(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})?)\s:\s(?:T:(?&amp;lt; ResponseTime&amp;gt;\S+\s+\S+))?(.)*(?&amp;lt;Action&amp;gt;(\w{3})):\s\[(?&amp;lt;XML&amp;gt;.*?)\]&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;This should handle the timeouts either existing in the log or not and only create the "timeout" field when they are there. Hope this helps!&lt;/P&gt;</description>
    <pubDate>Thu, 11 May 2017 14:26:26 GMT</pubDate>
    <dc:creator>beatus</dc:creator>
    <dc:date>2017-05-11T14:26:26Z</dc:date>
    <item>
      <title>Extract and Transform Custom Event</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Extract-and-Transform-Custom-Event/m-p/353234#M64694</link>
      <description>&lt;P&gt;I have events with the following format - &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[Thread-2505_GOOGLE_INT_20170424155901301f9e61-1493049600619-NSRLM_2_1_RTL_39088504_2_R_PCLN,PCLN] 2017-04-24 12:00:02 : T:0.047 secs S:XXXX-SSSS-SSSSSS A:Availability M:INT_20170424155901301f9e61-1493049600619-NSRLM_2_1_RTL_39088504_2_R_1 CMD: [&amp;lt;?xml version="1.0" ?&amp;gt;&amp;lt;AvailabilityRequestV2 xmlns="http://xml.google.com" siteid="1470249" apikey="SFGSDGSDFSDFGSFG" async="false" waittime="5"&amp;gt;&amp;lt;Type&amp;gt;4&amp;lt;/Type&amp;gt;&amp;lt;Id&amp;gt;460573&amp;lt;/Id&amp;gt;&amp;lt;Radius&amp;gt;0&amp;lt;/Radius&amp;gt;&amp;lt;Latitude&amp;gt;0.0&amp;lt;/Latitude&amp;gt;&amp;lt;Longitude&amp;gt;0.0&amp;lt;/Longitude&amp;gt;&amp;lt;CheckIn&amp;gt;2017-10-01&amp;lt;/CheckIn&amp;gt;&amp;lt;CheckOut&amp;gt;2017-10-17&amp;lt;/CheckOut&amp;gt;&amp;lt;Rooms&amp;gt;1&amp;lt;/Rooms&amp;gt;&amp;lt;Adults&amp;gt;2&amp;lt;/Adults&amp;gt;&amp;lt;Children&amp;gt;0&amp;lt;/Children&amp;gt;&amp;lt;Language&amp;gt;en-us&amp;lt;/Language&amp;gt;&amp;lt;Currency&amp;gt;000&amp;lt;/Currency&amp;gt;&amp;lt;/AvailabilityRequestV2&amp;gt;]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Notice couple of things - event starts with a thread name in square brackets, followed by date/time, followed by an unwanted ":", followed by several key/value pairs separated by a ":", and finally at the end you have content in XML inside square brackets.&lt;/P&gt;

&lt;P&gt;I want to extract/transform this into the following so it is easy to search and run spath to extract fields from xml - &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; Thread = Thread-2505_GOOGLE_INT_20170424155901301f9e61-1493049600619-NSRLM_2_1_RTL_39088504_2_R_PCLN,PCLN
DateTime = 2017-04-24 12:00:02
ResponseTime = 0.047 secs 
S = XXXX-SSSS-SSSSSS 
A = Availability 
M = INT_20170424155901301f9e61-1493049600619-NSRLM_2_1_RTL_39088504_2_R_1 
Action = CMD
XML = &amp;lt;?xml version="1.0" ?&amp;gt;&amp;lt;AvailabilityRequestV2 xmlns="http://xml.google.com" siteid="1470249" apikey="SFGSDGSDFSDFGSFG" async="false" waittime="5"&amp;gt;&amp;lt;Type&amp;gt;4&amp;lt;/Type&amp;gt;&amp;lt;Id&amp;gt;460573&amp;lt;/Id&amp;gt;&amp;lt;Radius&amp;gt;0&amp;lt;/Radius&amp;gt;&amp;lt;Latitude&amp;gt;0.0&amp;lt;/Latitude&amp;gt;&amp;lt;Longitude&amp;gt;0.0&amp;lt;/Longitude&amp;gt;&amp;lt;CheckIn&amp;gt;2017-10-01&amp;lt;/CheckIn&amp;gt;&amp;lt;CheckOut&amp;gt;2017-10-17&amp;lt;/CheckOut&amp;gt;&amp;lt;Rooms&amp;gt;1&amp;lt;/Rooms&amp;gt;&amp;lt;Adults&amp;gt;2&amp;lt;/Adults&amp;gt;&amp;lt;Children&amp;gt;0&amp;lt;/Children&amp;gt;&amp;lt;Language&amp;gt;en-us&amp;lt;/Language&amp;gt;&amp;lt;Currency&amp;gt;000&amp;lt;/Currency&amp;gt;&amp;lt;/AvailabilityRequestV2&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Notice that the last key CMD is put into a new key "Action" and value is put inside XML. I was able to do some clean up like removing square brackets, removing extra ":" etc with the following SED Command - &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;SEDCMD-remove-xml-header = s/\&amp;lt;\?xml[^\&amp;gt;]*\&amp;gt;//g
SEDCMD-remove-square-brackets = s/\[|\]//g
SEDCMD-remove-colon = s/ : / /g
SECCMD-reame-threadname = s/Thread-/Thread:/1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;How do I achieve the rest? Is a key value transformer? &lt;/P&gt;</description>
      <pubDate>Fri, 28 Apr 2017 11:21:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Extract-and-Transform-Custom-Event/m-p/353234#M64694</guid>
      <dc:creator>jagadeeshm</dc:creator>
      <dc:date>2017-04-28T11:21:02Z</dc:date>
    </item>
    <item>
      <title>Re: Extract and Transform Custom Event</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Extract-and-Transform-Custom-Event/m-p/353235#M64695</link>
      <description>&lt;P&gt;Any splunk transformers &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; around?&lt;/P&gt;</description>
      <pubDate>Mon, 01 May 2017 22:49:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Extract-and-Transform-Custom-Event/m-p/353235#M64695</guid>
      <dc:creator>jagadeeshm</dc:creator>
      <dc:date>2017-05-01T22:49:21Z</dc:date>
    </item>
    <item>
      <title>Re: Extract and Transform Custom Event</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Extract-and-Transform-Custom-Event/m-p/353236#M64696</link>
      <description>&lt;P&gt;Here's a regex that should work for you:&lt;BR /&gt;
&lt;CODE&gt;\[(?&amp;lt;Thread&amp;gt;.*?)\]\s(?&amp;lt;TimeStamp&amp;gt;(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})?)\s:\s(?:T:(?&amp;lt; ResponseTime&amp;gt;\S+\s+\S+))?(.)*(?&amp;lt;Action&amp;gt;(\w{3})):\s\[(?&amp;lt;XML&amp;gt;.*?)\]&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;This should handle the timeouts either existing in the log or not and only create the "timeout" field when they are there. Hope this helps!&lt;/P&gt;</description>
      <pubDate>Thu, 11 May 2017 14:26:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Extract-and-Transform-Custom-Event/m-p/353236#M64696</guid>
      <dc:creator>beatus</dc:creator>
      <dc:date>2017-05-11T14:26:26Z</dc:date>
    </item>
    <item>
      <title>Re: Extract and Transform Custom Event</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Extract-and-Transform-Custom-Event/m-p/353237#M64697</link>
      <description>&lt;P&gt;Thanks beatus &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 11 May 2017 14:29:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Extract-and-Transform-Custom-Event/m-p/353237#M64697</guid>
      <dc:creator>jagadeeshm</dc:creator>
      <dc:date>2017-05-11T14:29:05Z</dc:date>
    </item>
  </channel>
</rss>

