<?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: Extracting File Names from URL String in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Extracting-File-Names-from-URL-String/m-p/25629#M177582</link>
    <description>&lt;P&gt;but of course, that's what you're searching for.&lt;/P&gt;

&lt;P&gt;You could add a &lt;CODE&gt;| search file_extract=*&lt;/CODE&gt; at the end, which requires that the field exists, regardless of its value, The field will not be set if the rex does not match.&lt;/P&gt;

&lt;P&gt;/k&lt;/P&gt;</description>
    <pubDate>Tue, 07 May 2013 14:39:38 GMT</pubDate>
    <dc:creator>kristian_kolb</dc:creator>
    <dc:date>2013-05-07T14:39:38Z</dc:date>
    <item>
      <title>Extracting File Names from URL String</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extracting-File-Names-from-URL-String/m-p/25624#M177577</link>
      <description>&lt;P&gt;Hello All,&lt;/P&gt;

&lt;P&gt;Having some trouble coming up with a way to extract a file with three random characters and a .jnlp extension from the URI.&lt;/P&gt;

&lt;P&gt;Here is what I've attempted to so far. Any assistance would be greatly appreciated.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=wsa .jnlp | rex field=csurl (?) | regex csurl="\/[a-z0-9]{3}.jnlp$"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 06 May 2013 18:15:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extracting-File-Names-from-URL-String/m-p/25624#M177577</guid>
      <dc:creator>TucoRameriz</dc:creator>
      <dc:date>2013-05-06T18:15:49Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting File Names from URL String</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extracting-File-Names-from-URL-String/m-p/25625#M177578</link>
      <description>&lt;P&gt;If you have the field &lt;CODE&gt;csurl&lt;/CODE&gt; already defined, something like this should work.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=wsa csurl=*.jnlp | rex field=csurl "(?&amp;lt;my_new_field&amp;gt;\w{3})\.jnlp$"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If the filename (excluding the extension) is shorter than 3 - the field extraction will fail. If the filename (excluding extension) is longer than 3 - only the last 3 will be extracted into the new field.&lt;/P&gt;

&lt;P&gt;/k&lt;/P&gt;</description>
      <pubDate>Mon, 06 May 2013 20:04:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extracting-File-Names-from-URL-String/m-p/25625#M177578</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2013-05-06T20:04:08Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting File Names from URL String</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extracting-File-Names-from-URL-String/m-p/25626#M177579</link>
      <description>&lt;P&gt;Thanks for the reply.  The one question I have is in regards to the new field?  Rex field extraction is not one of my strong points yet.  Do I just give it a random name?&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 06 May 2013 20:51:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extracting-File-Names-from-URL-String/m-p/25626#M177579</guid>
      <dc:creator>TucoRameriz</dc:creator>
      <dc:date>2013-05-06T20:51:54Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting File Names from URL String</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extracting-File-Names-from-URL-String/m-p/25627#M177580</link>
      <description>&lt;P&gt;Well. Perhaps not &lt;EM&gt;random&lt;/EM&gt;, but more or less arbitrary. Some hints, though: &lt;BR /&gt;
- Use underscores instead of hyphens. &lt;BR /&gt;
- Must not start with a number.&lt;BR /&gt;
- Pick a name that makes sense. &lt;/P&gt;

&lt;P&gt;Remember that you can always change a field extraction later, but...if you do, you'll have to alter all &lt;CODE&gt;tags&lt;/CODE&gt;, &lt;CODE&gt;eventtype&lt;/CODE&gt;s, saved searches etc that uses the (old) field name. &lt;/P&gt;

&lt;P&gt;So if you have another log file that you want to correlate with, it could be a good idea to use the same field name here, e.g. a client ip address could/should always be extracted as &lt;CODE&gt;clientip&lt;/CODE&gt;, regardless of generating system.&lt;/P&gt;</description>
      <pubDate>Tue, 07 May 2013 07:20:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extracting-File-Names-from-URL-String/m-p/25627#M177580</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2013-05-07T07:20:21Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting File Names from URL String</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extracting-File-Names-from-URL-String/m-p/25628#M177581</link>
      <description>&lt;P&gt;Gave it a try and this string returns all .jnlp files.&lt;/P&gt;

&lt;P&gt;index=wsa cs_url=*.jnlp | rex field=cs_url "(?&lt;FILE_EXTRACT&gt;\w{3}).jnlp$"&lt;/FILE_EXTRACT&gt;&lt;/P&gt;

&lt;P&gt;Any thoughts&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 13:51:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extracting-File-Names-from-URL-String/m-p/25628#M177581</guid>
      <dc:creator>TucoRameriz</dc:creator>
      <dc:date>2020-09-28T13:51:02Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting File Names from URL String</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extracting-File-Names-from-URL-String/m-p/25629#M177582</link>
      <description>&lt;P&gt;but of course, that's what you're searching for.&lt;/P&gt;

&lt;P&gt;You could add a &lt;CODE&gt;| search file_extract=*&lt;/CODE&gt; at the end, which requires that the field exists, regardless of its value, The field will not be set if the rex does not match.&lt;/P&gt;

&lt;P&gt;/k&lt;/P&gt;</description>
      <pubDate>Tue, 07 May 2013 14:39:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extracting-File-Names-from-URL-String/m-p/25629#M177582</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2013-05-07T14:39:38Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting File Names from URL String</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extracting-File-Names-from-URL-String/m-p/25630#M177583</link>
      <description>&lt;P&gt;Wasn't that what you required? Give an input and expected output example&lt;/P&gt;</description>
      <pubDate>Tue, 07 May 2013 14:41:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extracting-File-Names-from-URL-String/m-p/25630#M177583</guid>
      <dc:creator>krugger</dc:creator>
      <dc:date>2013-05-07T14:41:26Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting File Names from URL String</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extracting-File-Names-from-URL-String/m-p/25631#M177584</link>
      <description>&lt;P&gt;I was looking to extract only JNLP files with a three character file name 123.jnlp or abc.jnlp&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 07 May 2013 15:05:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extracting-File-Names-from-URL-String/m-p/25631#M177584</guid>
      <dc:creator>TucoRameriz</dc:creator>
      <dc:date>2013-05-07T15:05:17Z</dc:date>
    </item>
  </channel>
</rss>

