<?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: Searching a URL for file name that may contain spaces in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Searching-a-URL-for-file-name-that-may-contain-spaces/m-p/285897#M175580</link>
    <description>&lt;P&gt;Thanks...  I was able to get it to work via the query below.  I was trying to pull the status code out of the record also, which I am still having issues with.  &lt;/P&gt;

&lt;P&gt;I tried the basic \s+\S+){5,6}$ in Regex101 and it seemed to pull properly, but what I have isn't assigning the correct code. Its pulling part of the NNNN in the filename. Also, we're pulling the file size from the record also which seems to be out of alignment now. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="ti_is_st" sourcetype="xfer_log" | rex field=_raw "^(\S+\s+){8}\/(([^\s\/]+\/)+)(?.+)(\s+\S+){8}$" |rex field=_raw "(\s+\S+){5,6}$(?.+(i|j|k|o|p|q))\s"|search "$field2$" "$field3$" |table _time ip_address Service_Account fileName file_size status |replace o with "Download Successful" i with "Upload Successful" j with "Upload Errored" k with "Upload Aborted" p with "Download Errored" q with "Download Aborted" in status
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Record:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Wed Oct 26 10:41:14 2016 0 10.40.112.27 437434 /dirlevel1/dirlevel2/dirlevel3/dirlevel4/chr 2610 4109.txt b s o r aaa_aaaaaaa ssh 0 *
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 15 Feb 2017 14:16:31 GMT</pubDate>
    <dc:creator>Mkaz</dc:creator>
    <dc:date>2017-02-15T14:16:31Z</dc:date>
    <item>
      <title>Searching a URL for file name that may contain spaces</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Searching-a-URL-for-file-name-that-may-contain-spaces/m-p/285885#M175568</link>
      <description>&lt;P&gt;Have a record in a log that looks like the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Wed Oct 26 10:41:14 2016 0 10.40.112.27 437434 /dirlevel1/dirlevel2/dirlevel3/dirlevel4/chr 2610 4109.txt b s o r aaa_aaaaaaa ssh 0 *
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The record is delimited by spaces. I'm trying to pull the filename from the directory provided: &lt;CODE&gt;/dirlevel1/dirlevel2/dirlevel3/dirlevel4/chr 2610 4109.txt&lt;/CODE&gt; &lt;/P&gt;

&lt;P&gt;The issue I'm running into is that the file name may have a space or multiple spaces in it.  The following code works, but provides the next set of filed values when it runs into a space within the file name.  If the search can be performed from right to left starting at the "b" in the 8th field from the left and take everything from that point to the right up till the first "/" that would be fine.  Not sure how to do that though?  Any suggestions?&lt;/P&gt;

&lt;P&gt;Code used is:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="ti_is_st" sourcetype="xfer_log" URI=* Status=* IP_Address=* File_Size=* Service_Account=*| rex field=URI "\/(([^\s\/]+\/)*)(?&amp;lt;fileName&amp;gt;[\S]+)" |search fileName="*" Service_Account="*"|table _time IP_Address Service_Account fileName File_Size Status  |replace o with "Download Successful" i with "Upload Successful" j with "Upload Errored" k with "Upload Aborted"  p with "Download Errored" q with "Download Aborted" in Status
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 13 Feb 2017 15:58:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Searching-a-URL-for-file-name-that-may-contain-spaces/m-p/285885#M175568</guid>
      <dc:creator>Mkaz</dc:creator>
      <dc:date>2017-02-13T15:58:42Z</dc:date>
    </item>
    <item>
      <title>Re: Searching a URL for file name that may contain spaces</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Searching-a-URL-for-file-name-that-may-contain-spaces/m-p/285886#M175569</link>
      <description>&lt;P&gt;Give this a try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="ti_is_st" sourcetype="xfer_log" URI=* Status=* IP_Address=* File_Size=* Service_Account=*| rex field=_raw "^(\S+\s+){8}\/(([^\s\/]+\/)+)(?&amp;lt;fileName&amp;gt;.+)(\s+\S+){8}$" |search fileName="*" Service_Account="*"|table _time IP_Address Service_Account fileName File_Size Status  |replace o with "Download Successful" i with "Upload Successful" j with "Upload Errored" k with "Upload Aborted"  p with "Download Errored" q with "Download Aborted" in Status
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 13 Feb 2017 17:04:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Searching-a-URL-for-file-name-that-may-contain-spaces/m-p/285886#M175569</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-02-13T17:04:07Z</dc:date>
    </item>
    <item>
      <title>Re: Searching a URL for file name that may contain spaces</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Searching-a-URL-for-file-name-that-may-contain-spaces/m-p/285887#M175570</link>
      <description>&lt;P&gt;Hello, I don't understand the question very well (Maybe is my English :D) but I think you want to extract this:&lt;/P&gt;

&lt;P&gt;/dirlevel1/dirlevel2/dirlevel3/dirlevel4/chr 2610 4109.txt&lt;/P&gt;

&lt;P&gt;Am I right? &lt;/P&gt;

&lt;P&gt;I think your problem is regex, if you help me with more information I might help you. &lt;/P&gt;</description>
      <pubDate>Mon, 13 Feb 2017 17:07:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Searching-a-URL-for-file-name-that-may-contain-spaces/m-p/285887#M175570</guid>
      <dc:creator>jrballesteros05</dc:creator>
      <dc:date>2017-02-13T17:07:49Z</dc:date>
    </item>
    <item>
      <title>Re: Searching a URL for file name that may contain spaces</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Searching-a-URL-for-file-name-that-may-contain-spaces/m-p/285888#M175571</link>
      <description>&lt;P&gt;Thanks for your response...&lt;/P&gt;

&lt;P&gt;Well...  Yes, basically just trying to pull the complete filename including the spaces only.  The "/dirlevel1/dirlevel2/dirlevel3/dirlevel4/" is not required.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Feb 2017 17:38:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Searching-a-URL-for-file-name-that-may-contain-spaces/m-p/285888#M175571</guid>
      <dc:creator>Mkaz</dc:creator>
      <dc:date>2017-02-13T17:38:50Z</dc:date>
    </item>
    <item>
      <title>Re: Searching a URL for file name that may contain spaces</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Searching-a-URL-for-file-name-that-may-contain-spaces/m-p/285889#M175572</link>
      <description>&lt;P&gt;Thanks for your response...&lt;/P&gt;

&lt;P&gt;This sits in a query statement and is throwing an error: Encountered the following error while trying to update: In handler 'views': Error parsing XML on line 37: Premature end of data in tag form line 1 &lt;/P&gt;</description>
      <pubDate>Mon, 13 Feb 2017 17:41:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Searching-a-URL-for-file-name-that-may-contain-spaces/m-p/285889#M175572</guid>
      <dc:creator>Mkaz</dc:creator>
      <dc:date>2017-02-13T17:41:41Z</dc:date>
    </item>
    <item>
      <title>Re: Searching a URL for file name that may contain spaces</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Searching-a-URL-for-file-name-that-may-contain-spaces/m-p/285890#M175573</link>
      <description>&lt;P&gt;Are you updating the query in dashboard from Edit -&amp;gt; Source xml option?&lt;BR /&gt;
If yes,then use this &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="ti_is_st" sourcetype="xfer_log" URI=* Status=* IP_Address=* File_Size=* Service_Account=*| rex field=_raw "^(\S+\s+){8}\/(([^\s\/]+\/)+)(?&amp;amp;lt;fileName&amp;amp;gt;.+)(\s+\S+){8}$" |search fileName="*" Service_Account="*"|table _time IP_Address Service_Account fileName File_Size Status  |replace o with "Download Successful" i with "Upload Successful" j with "Upload Errored" k with "Upload Aborted"  p with "Download Errored" q with "Download Aborted" in Status
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 13 Feb 2017 17:50:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Searching-a-URL-for-file-name-that-may-contain-spaces/m-p/285890#M175573</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-02-13T17:50:00Z</dc:date>
    </item>
    <item>
      <title>Re: Searching a URL for file name that may contain spaces</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Searching-a-URL-for-file-name-that-may-contain-spaces/m-p/285891#M175574</link>
      <description>&lt;P&gt;Great thanks...  Tried it and its close.  Its pulling the file name correctly but not the status filed.  In the record below, its pulling a status of "of" as opposed to the "o" which would be converted to Download Successful.  Its happening on all records that have a space in the file name.  This one happened to have several spaces.&lt;/P&gt;

&lt;P&gt;Record:&lt;BR /&gt;
NNN NNNNN aaaaa-Aaaa of Aaaaaa Aaaaaa NNNN.xls b s o r AAAAAA ssh 0 *&lt;/P&gt;</description>
      <pubDate>Mon, 13 Feb 2017 18:04:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Searching-a-URL-for-file-name-that-may-contain-spaces/m-p/285891#M175574</guid>
      <dc:creator>Mkaz</dc:creator>
      <dc:date>2017-02-13T18:04:22Z</dc:date>
    </item>
    <item>
      <title>Re: Searching a URL for file name that may contain spaces</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Searching-a-URL-for-file-name-that-may-contain-spaces/m-p/285892#M175575</link>
      <description>&lt;P&gt;Hello, if you only need the filename. I would do it in two ways.&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;&lt;P&gt;If the filename comes with the metadata "source" you can extract in the props.conf and create a new field: &lt;/P&gt;

&lt;P&gt;EXTRACT-filename=\S+\/(?P&lt;FILENAME&gt;.*?).txt in source&lt;/FILENAME&gt;&lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;P&gt;If the filename does not come with the metadata "source", you can use the &lt;/P&gt;

&lt;P&gt;index="ti_is_st" sourcetype="xfer_log" URI=* Status=* IP_Address=* File_Size=* Service_Account=&lt;EM&gt;| rex field=_raw "\S+\/(?P&lt;FILENAME&gt;.&lt;/FILENAME&gt;&lt;/EM&gt;?).txt" |search fileName="&lt;EM&gt;" Service_Account="&lt;/EM&gt;"|table _time IP_Address Service_Account fileName File_Size Status  |replace o with "Download Successful" i with "Upload Successful" j with "Upload Errored" k with "Upload Aborted"  p with "Download Errored" q with "Download Aborted" in Status&lt;BR /&gt;
In the two ways, the key is the regex you are using. I tried "\S+\/(.*?).txt" in regex101.com and it worked for me. &lt;/P&gt;&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;I hope this help you.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 12:50:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Searching-a-URL-for-file-name-that-may-contain-spaces/m-p/285892#M175575</guid>
      <dc:creator>jrballesteros05</dc:creator>
      <dc:date>2020-09-29T12:50:44Z</dc:date>
    </item>
    <item>
      <title>Re: Searching a URL for file name that may contain spaces</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Searching-a-URL-for-file-name-that-may-contain-spaces/m-p/285893#M175576</link>
      <description>&lt;P&gt;Thanks Jr...  My apologies for not stating this earlier, but the file names can end in multiple file formats such as .txt, .xls, .xfr, etc...  There would also be mainframes file that may be named aaaaa.aaaaaa.aaaaaaa.aaaaa.   &lt;/P&gt;</description>
      <pubDate>Mon, 13 Feb 2017 18:40:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Searching-a-URL-for-file-name-that-may-contain-spaces/m-p/285893#M175576</guid>
      <dc:creator>Mkaz</dc:creator>
      <dc:date>2017-02-13T18:40:39Z</dc:date>
    </item>
    <item>
      <title>Re: Searching a URL for file name that may contain spaces</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Searching-a-URL-for-file-name-that-may-contain-spaces/m-p/285894#M175577</link>
      <description>&lt;P&gt;Ok, you can use this regex.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;   \S+\/(?P&amp;lt;filename&amp;gt;.*?)\..*?\s+
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 13 Feb 2017 18:45:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Searching-a-URL-for-file-name-that-may-contain-spaces/m-p/285894#M175577</guid>
      <dc:creator>jrballesteros05</dc:creator>
      <dc:date>2017-02-13T18:45:54Z</dc:date>
    </item>
    <item>
      <title>Re: Searching a URL for file name that may contain spaces</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Searching-a-URL-for-file-name-that-may-contain-spaces/m-p/285895#M175578</link>
      <description>&lt;P&gt;How are you extracting Status field? I don't see a Status field being extracted in the query itself, so it's probably extracted using saved field extractions and you should check the regular expression their on why Status field is wrong for your sample event.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Feb 2017 19:32:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Searching-a-URL-for-file-name-that-may-contain-spaces/m-p/285895#M175578</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-02-13T19:32:09Z</dc:date>
    </item>
    <item>
      <title>Re: Searching a URL for file name that may contain spaces</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Searching-a-URL-for-file-name-that-may-contain-spaces/m-p/285896#M175579</link>
      <description>&lt;P&gt;This is the full query we're using.  I tried the basic \s+\S+){5,6}$ in Regex101 and it seemed to pull properly, but what I have isn't assigning the correct code.  Its pulling part of the NNNN in the filename.  Also, we're pulling the file size from the record also which seems to be out of alignment now. &lt;/P&gt;

&lt;P&gt;index="ti_is_st" sourcetype="xfer_log" | rex field=_raw "^(\S+\s+){8}\/(([^\s\/]+\/)+)(?&amp;lt;fileName&amp;gt;.+)(\s+\S+){8}$" |rex field=_raw "(\s+\S+){5,6}$(?&amp;lt;status&amp;gt;.+(i|j|k|o|p|q))\s"|search "&lt;EM&gt;$field2$&lt;/EM&gt;" "&lt;EM&gt;$field3$&lt;/EM&gt;" |table _time ip_address Service_Account fileName file_size status  |replace o with "Download Successful" i with "Upload Successful" j with "Upload Errored" k with "Upload Aborted"  p with "Download Errored" q with "Download Aborted" in status&lt;/P&gt;

&lt;P&gt;Record:&lt;/P&gt;

&lt;P&gt;Wed Oct 26 10:41:14 2016 0 10.40.112.27 437434 /dirlevel1/dirlevel2/dirlevel3/dirlevel4/chr 2610 4109.txt b s o r aaa_aaaaaaa ssh 0 *&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 12:52:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Searching-a-URL-for-file-name-that-may-contain-spaces/m-p/285896#M175579</guid>
      <dc:creator>Mkaz</dc:creator>
      <dc:date>2020-09-29T12:52:06Z</dc:date>
    </item>
    <item>
      <title>Re: Searching a URL for file name that may contain spaces</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Searching-a-URL-for-file-name-that-may-contain-spaces/m-p/285897#M175580</link>
      <description>&lt;P&gt;Thanks...  I was able to get it to work via the query below.  I was trying to pull the status code out of the record also, which I am still having issues with.  &lt;/P&gt;

&lt;P&gt;I tried the basic \s+\S+){5,6}$ in Regex101 and it seemed to pull properly, but what I have isn't assigning the correct code. Its pulling part of the NNNN in the filename. Also, we're pulling the file size from the record also which seems to be out of alignment now. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="ti_is_st" sourcetype="xfer_log" | rex field=_raw "^(\S+\s+){8}\/(([^\s\/]+\/)+)(?.+)(\s+\S+){8}$" |rex field=_raw "(\s+\S+){5,6}$(?.+(i|j|k|o|p|q))\s"|search "$field2$" "$field3$" |table _time ip_address Service_Account fileName file_size status |replace o with "Download Successful" i with "Upload Successful" j with "Upload Errored" k with "Upload Aborted" p with "Download Errored" q with "Download Aborted" in status
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Record:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Wed Oct 26 10:41:14 2016 0 10.40.112.27 437434 /dirlevel1/dirlevel2/dirlevel3/dirlevel4/chr 2610 4109.txt b s o r aaa_aaaaaaa ssh 0 *
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 15 Feb 2017 14:16:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Searching-a-URL-for-file-name-that-may-contain-spaces/m-p/285897#M175580</guid>
      <dc:creator>Mkaz</dc:creator>
      <dc:date>2017-02-15T14:16:31Z</dc:date>
    </item>
  </channel>
</rss>

