<?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 fields from URL in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Extract-fields-from-URL/m-p/295116#M89070</link>
    <description>&lt;P&gt;Hello Giuseppe,&lt;/P&gt;

&lt;P&gt;I am using IFX to extract separate fields for each of them,Can you please help me with regex for each of the field like the one you mentioned for ID&lt;/P&gt;

&lt;P&gt;Thanks for your time&lt;/P&gt;</description>
    <pubDate>Sat, 19 Aug 2017 16:18:08 GMT</pubDate>
    <dc:creator>vrmandadi</dc:creator>
    <dc:date>2017-08-19T16:18:08Z</dc:date>
    <item>
      <title>Extract fields from URL</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-fields-from-URL/m-p/295112#M89066</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;I have the below URL Types and I am trying to extract 3 fields from them&lt;/P&gt;

&lt;P&gt;LIVE as form&lt;BR /&gt;
hls as rule&lt;BR /&gt;
TWAMCPH as mode&lt;/P&gt;

&lt;P&gt;URL&lt;BR /&gt;
Example URL1:&lt;BR /&gt;
&lt;A href="http://linear-scope010.abc.com/LIVE/1002/hls/ae/TWAMCPH/98.m3u8" target="_blank"&gt;http://linear-scope010.abc.com/LIVE/1002/hls/ae/TWAMCPH/98.m3u8&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;ExampleURL2:&lt;BR /&gt;
&lt;A href="http://mmdai-linear-west-03.abc.com/linear-scope010.abc.com/LIVE/1008/hls/ae/Nat_HD/.swn71c39e69-9b76-45a0-a2da-005056b23b1dapple2apple/.rate_2737280/index_v_2737280_6.m3u8?nw=376521&amp;amp;prof=376521:twc_hls_live&amp;amp;mode=live&amp;amp;vdur=600&amp;amp;caid=NGC_LIVE&amp;amp;csid=stva_android_ph_live&amp;amp;vcid=369573a4-4f5b-3aa7-a42b-2eec0477efda&amp;amp;z5=79912&amp;amp;ads=VAST_LIVE&amp;amp;tagset_name=VAST&amp;amp;_fw_lpu=http://linear-scope010.abc.com/LIVE/1008/hl" target="_blank"&gt;http://mmdai-linear-west-03.abc.com/linear-scope010.abc.com/LIVE/1008/hls/ae/Nat_HD/.swn71c39e69-9b76-45a0-a2da-005056b23b1dapple2apple/.rate_2737280/index_v_2737280_6.m3u8?nw=376521&amp;amp;prof=376521:twc_hls_live&amp;amp;mode=live&amp;amp;vdur=600&amp;amp;caid=NGC_LIVE&amp;amp;csid=stva_android_ph_live&amp;amp;vcid=369573a4-4f5b-3aa7-a42b-2eec0477efda&amp;amp;z5=79912&amp;amp;ads=VAST_LIVE&amp;amp;tagset_name=VAST&amp;amp;_fw_lpu=http://linear-scope010.abc.com/LIVE/1008/hl&lt;/A&gt;...&lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;Help with regex to extract a particular field- I want to extract the  numbers after as Identity which are in BOLD in the below sample event&lt;BR /&gt;
Identity: 33752527&lt;/P&gt;

&lt;P&gt;Sample event:&lt;/P&gt;

&lt;P&gt;19 Aug 2017 01:09:41 [WARN ] http_srv: DONE 5018465 0.010309 404[Not Found] UNKNOWN-ID 69.134.235.12:12113 GET &lt;A href="http://mmdai-linear-west-03.abc.com/linear-scope010.abc.com/LIVE/1008/hls/ae/Nat_HD/.swn71c39e69-9b76-45a0-a2da-005056b23b1dapple2apple/.rate_2737280/index_v_2737280_6.m3u8?nw=376521&amp;amp;prof=376521:twc_hls_live&amp;amp;mode=live&amp;amp;vdur=600&amp;amp;caid=NGC_LIVE&amp;amp;csid=stva_android_ph_live&amp;amp;vcid=369573a4-4f5b-3aa7-a42b-2eec0477efda&amp;amp;z5=79912&amp;amp;ads=VAST_LIVE&amp;amp;tagset_name=VAST&amp;amp;_fw_lpu=http://linear-scope010.abc.com/LIVE/1008/hl" target="_blank"&gt;http://mmdai-linear-west-03.abc.com/linear-scope010.abc.com/LIVE/1008/hls/ae/Nat_HD/.swn71c39e69-9b76-45a0-a2da-005056b23b1dapple2apple/.rate_2737280/index_v_2737280_6.m3u8?nw=376521&amp;amp;prof=376521:twc_hls_live&amp;amp;mode=live&amp;amp;vdur=600&amp;amp;caid=NGC_LIVE&amp;amp;csid=stva_android_ph_live&amp;amp;vcid=369573a4-4f5b-3aa7-a42b-2eec0477efda&amp;amp;z5=79912&amp;amp;ads=VAST_LIVE&amp;amp;tagset_name=VAST&amp;amp;_fw_lpu=http://linear-scope010.abc.com/LIVE/1008/hl&lt;/A&gt;... (id &lt;STRONG&gt;33752527&lt;/STRONG&gt;)&lt;/P&gt;

&lt;P&gt;Sample event 2:&lt;/P&gt;

&lt;P&gt;19 Aug 2017 01:16:22 [WARN ] http_cli: Origin latency exceeded threshold: 0.068990 seconds GET Status: 200[OK] Bytes: 10079 Origin URL: &lt;A href="http://linear-scope010.abc.com/LIVE/1008/hls/ae/FX_HD/98.m3u8" target="_blank"&gt;http://linear-scope010.abc.com/LIVE/1008/hls/ae/FX_HD/98.m3u8&lt;/A&gt; refReqId 34040636 reqWait 0 (id &lt;STRONG&gt;3291791648&lt;/STRONG&gt;)&lt;/P&gt;

&lt;P&gt;Sample event 3:&lt;/P&gt;

&lt;P&gt;19 Aug 2017 01:16:22 [WARN ] http_srv: Total latency exceeded threshold: 0.054962 seconds (internal 0.055000 s) origin 0.000000 seconds MCHit 0 Status: 404 IP: 69.134.235.13:9290 URL: &lt;A href="http://mmdai-linear-west-03.abc.com/linear-scope010.abc.com/LIVE/1007/hls/ae/MSNBC_HD/.swn0f1c1094-9a82-4a38-9396-005056b23b1dapple2apple/.rate_730944/index_v_730944_2.m3u8?nw=376521&amp;amp;prof=376521:twc_hls_live&amp;amp;mode=live&amp;amp;vdur=600&amp;amp;caid=MSNBC_LIVE&amp;amp;csid=stva_roku_tv_live&amp;amp;vcid=54550573-abff-36b4-b9aa-78deceeccdc6&amp;amp;z5=76051&amp;amp;ads=VAST_LIVE&amp;amp;tagset_n" target="_blank"&gt;http://mmdai-linear-west-03.abc.com/linear-scope010.abc.com/LIVE/1007/hls/ae/MSNBC_HD/.swn0f1c1094-9a82-4a38-9396-005056b23b1dapple2apple/.rate_730944/index_v_730944_2.m3u8?nw=376521&amp;amp;prof=376521:twc_hls_live&amp;amp;mode=live&amp;amp;vdur=600&amp;amp;caid=MSNBC_LIVE&amp;amp;csid=stva_roku_tv_live&amp;amp;vcid=54550573-abff-36b4-b9aa-78deceeccdc6&amp;amp;z5=76051&amp;amp;ads=VAST_LIVE&amp;amp;tagset_n&lt;/A&gt;... (id &lt;STRONG&gt;34040648&lt;/STRONG&gt;)&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 15:27:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-fields-from-URL/m-p/295112#M89066</guid>
      <dc:creator>vrmandadi</dc:creator>
      <dc:date>2020-09-29T15:27:44Z</dc:date>
    </item>
    <item>
      <title>Re: Extract fields from URL</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-fields-from-URL/m-p/295113#M89067</link>
      <description>&lt;P&gt;Hi vrmandadi,&lt;BR /&gt;
regex to extract the second one you asked it's no difficoult:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;\(id\s(?&amp;lt;identity&amp;gt;\d+)\)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;test it at &lt;A href="https://regex101.com/r/F1dWey/1"&gt;https://regex101.com/r/F1dWey/1&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;The problem is the first one because you have two different paths with a different number of segments before the form field:&lt;BR /&gt;
If your sure that after "LIVE" there's a number, you can use this one:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;\/(?&amp;lt;form&amp;gt;[^\/]*)\/\d+\/(?&amp;lt;rule&amp;gt;[^\/]*)\/\w+\/(?&amp;lt;mode&amp;gt;[^\/]*)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;test it at &lt;A href="https://regex101.com/r/HaU7mr/1"&gt;https://regex101.com/r/HaU7mr/1&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Sat, 19 Aug 2017 06:28:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-fields-from-URL/m-p/295113#M89067</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2017-08-19T06:28:50Z</dc:date>
    </item>
    <item>
      <title>Re: Extract fields from URL</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-fields-from-URL/m-p/295114#M89068</link>
      <description>&lt;P&gt;@vrmandadi, your field extraction is a bit complicated only because you are looking at two different log patterns &lt;CODE&gt;http_srv&lt;/CODE&gt; and &lt;CODE&gt;http_cli&lt;/CODE&gt;. Are these both coming from same log (or source/sourcetype), or is it your query which has brought them together? You use case would be simpler if these are two separate sources or sourcetypes (so please confirm).&lt;/P&gt;

&lt;P&gt;In case both the type of events are in the same source/sourcetype, you can try the following&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; &amp;lt;YourBaseSearch&amp;gt;
| rex field=_raw "http:\/\/(?&amp;lt;URL&amp;gt;[^\s]+)\s"
| rex field=_raw "\(id\s(?&amp;lt;id&amp;gt;\d+)\)"
| eval URL=split(URL,"/")
| table id URL
| eval index=if(match(mvindex(URL,1),".com"),"1,2,3","0,1,2")
| eval index=split(index,",")
| eval firstIndex=mvindex(index,0)
| eval secondIndex=mvindex(index,1)
| eval thirdIndex=mvindex(index,2)
| eval form=mvindex(URL,firstIndex)
| eval rule=mvindex(URL,secondIndex)
| eval mode=mvindex(URL,thirdIndex)
| table id form mode rule
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 19 Aug 2017 12:07:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-fields-from-URL/m-p/295114#M89068</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-08-19T12:07:12Z</dc:date>
    </item>
    <item>
      <title>Re: Extract fields from URL</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-fields-from-URL/m-p/295115#M89069</link>
      <description>&lt;P&gt;Hello niketnilay,&lt;/P&gt;

&lt;P&gt;I am trying to extract those fields and create new fields using the IFX, but its not successful since they dont follow a pattern and they are from same sourcetype.&lt;/P&gt;

&lt;P&gt;I want help with the regex to extract &lt;BR /&gt;
LIVE as form&lt;BR /&gt;
hls as rule&lt;BR /&gt;
TWAMCPH as mode    ..Can you please help with regex for each field to extract&lt;/P&gt;</description>
      <pubDate>Sat, 19 Aug 2017 16:09:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-fields-from-URL/m-p/295115#M89069</guid>
      <dc:creator>vrmandadi</dc:creator>
      <dc:date>2017-08-19T16:09:55Z</dc:date>
    </item>
    <item>
      <title>Re: Extract fields from URL</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-fields-from-URL/m-p/295116#M89070</link>
      <description>&lt;P&gt;Hello Giuseppe,&lt;/P&gt;

&lt;P&gt;I am using IFX to extract separate fields for each of them,Can you please help me with regex for each of the field like the one you mentioned for ID&lt;/P&gt;

&lt;P&gt;Thanks for your time&lt;/P&gt;</description>
      <pubDate>Sat, 19 Aug 2017 16:18:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-fields-from-URL/m-p/295116#M89070</guid>
      <dc:creator>vrmandadi</dc:creator>
      <dc:date>2017-08-19T16:18:08Z</dc:date>
    </item>
    <item>
      <title>Re: Extract fields from URL</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-fields-from-URL/m-p/295117#M89071</link>
      <description>&lt;P&gt;You can create a regex for &lt;CODE&gt;URL&lt;/CODE&gt; and &lt;CODE&gt;id&lt;/CODE&gt; since the regular expressions remains the same as that in the &lt;CODE&gt;rex&lt;/CODE&gt; command.&lt;/P&gt;

&lt;P&gt;You can move eval section to macro URL as input. However, give the two different types of events for &lt;CODE&gt;http_srv&lt;/CODE&gt; and &lt;CODE&gt;http_cli&lt;/CODE&gt;, I was not able to find same pattern applicable for both.&lt;/P&gt;</description>
      <pubDate>Sat, 19 Aug 2017 16:23:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-fields-from-URL/m-p/295117#M89071</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-08-19T16:23:46Z</dc:date>
    </item>
    <item>
      <title>Re: Extract fields from URL</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-fields-from-URL/m-p/295118#M89072</link>
      <description>&lt;P&gt;Hi vrmandadi,&lt;BR /&gt;
you don't need to create  a regex for each field, also using IFX you can have a single regex to extract more fields.&lt;/P&gt;

&lt;P&gt;Use IFX and when you arrive to the extraction, there's a link to show regex, click on it and then click on modify regex, so you can insert my regex with all the fields.&lt;/P&gt;

&lt;P&gt;Otherwise, if you already have regex, it's easier to create a new field from web interface but not using IFX, go in [Settings -- Fields -- Fields Extractions -- New], insert:&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;Destination App, &lt;/LI&gt;
&lt;LI&gt;a name for the extraction (e.g. form_rule_mode), &lt;/LI&gt;
&lt;LI&gt;sourcetype (it's the more important thing!) &lt;/LI&gt;
&lt;LI&gt;and finally the full regex; 
in few minutes you'll have your fields.&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;Remember that fields will not  be immediately available, but after a few minutes (I don't know why!).&lt;BR /&gt;
Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 15:27:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-fields-from-URL/m-p/295118#M89072</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2020-09-29T15:27:49Z</dc:date>
    </item>
    <item>
      <title>Re: Extract fields from URL</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-fields-from-URL/m-p/295119#M89073</link>
      <description>&lt;P&gt;Thank You Giuseppe.Thanks a lot &lt;/P&gt;</description>
      <pubDate>Sat, 19 Aug 2017 19:59:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-fields-from-URL/m-p/295119#M89073</guid>
      <dc:creator>vrmandadi</dc:creator>
      <dc:date>2017-08-19T19:59:52Z</dc:date>
    </item>
  </channel>
</rss>

