<?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: Conditional Field Extraction via props and transforms in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Conditional-Field-Extraction-via-props-and-transforms/m-p/75603#M19113</link>
    <description>&lt;P&gt;As requested I have added the props and sample events. Based on protocol I need two regex to extract the asset value from the field "URL".&lt;/P&gt;

&lt;P&gt;EXTRACT-router=^(?P&lt;C_IP&gt;\S+?)\s+(?P&lt;USER_AGENT&gt;\S+?)\s+(?P&lt;DATE&gt;\S+?)\s+(?P&lt;TIME&gt;\S+?)\s+(?P&lt;URL&gt;\S+?)\s+(?P&lt;PROTOCOL&gt;\S+?)\s+(?P&lt;STATUS&gt;\S+?)\s+(?P&lt;ROUTING_METHOD&gt;\S+?)\s*$&lt;/ROUTING_METHOD&gt;&lt;/STATUS&gt;&lt;/PROTOCOL&gt;&lt;/URL&gt;&lt;/TIME&gt;&lt;/DATE&gt;&lt;/USER_AGENT&gt;&lt;/C_IP&gt;&lt;/P&gt;

&lt;P&gt;10.11.12.13 WMPlayer 2013-04-04 03:49:59 rtsp://XXXXX.com/channelA?SIGV=adbfvbavbsbmsdbsvbha67v8776avavkjah89 RTSP 404 - &lt;BR /&gt;
10.11.12.14 Mozilla 2013-04-04 03:49:59 &lt;A href="http://XXXXX.com/ABC/123/456/DEFGHGJGJG/DragonsGate-270x390.jpg"&gt;http://XXXXX.com/ABC/123/456/DEFGHGJGJG/DragonsGate-270x390.jpg&lt;/A&gt; HTTP 302 -&lt;/P&gt;</description>
    <pubDate>Thu, 04 Apr 2013 03:58:36 GMT</pubDate>
    <dc:creator>KarunK</dc:creator>
    <dc:date>2013-04-04T03:58:36Z</dc:date>
    <item>
      <title>Conditional Field Extraction via props and transforms</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Conditional-Field-Extraction-via-props-and-transforms/m-p/75601#M19111</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;

&lt;P&gt;I have a couple searches like below to extract field based on a condition of existence of a string in the log.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="access_log" protocol="http" | rex field=url "&amp;lt;field_extraction_01&amp;gt;"
index="access_log" protocol="rtsp" | rex field=url "&amp;lt;field_extraction_02&amp;gt;"
index="access_log" protocol="rtmp" | rex field=url "&amp;lt;field_extraction_03&amp;gt;"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;How will I implement this search time  field extraction using props OR transforms ?&lt;/P&gt;

&lt;P&gt;Thanks in Advance.&lt;/P&gt;

&lt;P&gt;Cheers&lt;/P&gt;

&lt;P&gt;KK&lt;/P&gt;</description>
      <pubDate>Wed, 27 Mar 2013 05:56:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Conditional-Field-Extraction-via-props-and-transforms/m-p/75601#M19111</guid>
      <dc:creator>KarunK</dc:creator>
      <dc:date>2013-03-27T05:56:33Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Field Extraction via props and transforms</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Conditional-Field-Extraction-via-props-and-transforms/m-p/75602#M19112</link>
      <description>&lt;P&gt;I guess that you'd have to EXTRACT them for all events, or attempt to. Naturally they would fail in the case of a different protocol.&lt;/P&gt;

&lt;P&gt;If you could provide a few sample events, it would be easier to see if you need one or more EXTRACTs. Depending on the look of your events you could perhaps do something like;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[sourcetype]
EXTRACT-woo = proto=(http|rtsp|rtmp)\s+url=(?&amp;lt;field&amp;gt;\w+)[\w.-]+\s
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;/K&lt;/P&gt;</description>
      <pubDate>Wed, 27 Mar 2013 06:07:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Conditional-Field-Extraction-via-props-and-transforms/m-p/75602#M19112</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2013-03-27T06:07:25Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Field Extraction via props and transforms</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Conditional-Field-Extraction-via-props-and-transforms/m-p/75603#M19113</link>
      <description>&lt;P&gt;As requested I have added the props and sample events. Based on protocol I need two regex to extract the asset value from the field "URL".&lt;/P&gt;

&lt;P&gt;EXTRACT-router=^(?P&lt;C_IP&gt;\S+?)\s+(?P&lt;USER_AGENT&gt;\S+?)\s+(?P&lt;DATE&gt;\S+?)\s+(?P&lt;TIME&gt;\S+?)\s+(?P&lt;URL&gt;\S+?)\s+(?P&lt;PROTOCOL&gt;\S+?)\s+(?P&lt;STATUS&gt;\S+?)\s+(?P&lt;ROUTING_METHOD&gt;\S+?)\s*$&lt;/ROUTING_METHOD&gt;&lt;/STATUS&gt;&lt;/PROTOCOL&gt;&lt;/URL&gt;&lt;/TIME&gt;&lt;/DATE&gt;&lt;/USER_AGENT&gt;&lt;/C_IP&gt;&lt;/P&gt;

&lt;P&gt;10.11.12.13 WMPlayer 2013-04-04 03:49:59 rtsp://XXXXX.com/channelA?SIGV=adbfvbavbsbmsdbsvbha67v8776avavkjah89 RTSP 404 - &lt;BR /&gt;
10.11.12.14 Mozilla 2013-04-04 03:49:59 &lt;A href="http://XXXXX.com/ABC/123/456/DEFGHGJGJG/DragonsGate-270x390.jpg"&gt;http://XXXXX.com/ABC/123/456/DEFGHGJGJG/DragonsGate-270x390.jpg&lt;/A&gt; HTTP 302 -&lt;/P&gt;</description>
      <pubDate>Thu, 04 Apr 2013 03:58:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Conditional-Field-Extraction-via-props-and-transforms/m-p/75603#M19113</guid>
      <dc:creator>KarunK</dc:creator>
      <dc:date>2013-04-04T03:58:36Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Field Extraction via props and transforms</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Conditional-Field-Extraction-via-props-and-transforms/m-p/75604#M19114</link>
      <description>&lt;P&gt;You can use either props or transforms. But in any case make sure that you scope the extraction on the field of interest. If you can't produce a regex that alternates on protocol, you may need to have separate regexes for each case. Here's an example using &lt;CODE&gt;EXTRACT-xxx&lt;/CODE&gt; from props.conf. The "&lt;CODE&gt;in url&lt;/CODE&gt;" string after the regex, narrows the scope of the extraction only on the &lt;CODE&gt;url&lt;/CODE&gt; field. &lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;[my_stanza]&lt;BR /&gt;
EXTRACT-router= ...&lt;BR /&gt;
EXTRACT-url_asset_01 = my_regex_01 in url&lt;BR /&gt;
EXTRACT-url_asset_02 = my_regex_03 in url&lt;BR /&gt;
EXTRACT-url_asset_03 = my_regex_03 in url&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Apr 2013 04:15:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Conditional-Field-Extraction-via-props-and-transforms/m-p/75604#M19114</guid>
      <dc:creator>_d_</dc:creator>
      <dc:date>2013-04-04T04:15:56Z</dc:date>
    </item>
  </channel>
</rss>

