<?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: Regex Source and Destination files with path, filename, extension in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Regex-Source-and-Destination-files-with-path-filename-extension/m-p/271992#M81853</link>
    <description>&lt;P&gt;This works with your sample data.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | rex field=Additional_Data "(?&amp;lt;source_path&amp;gt;.*?)\\(?&amp;lt;source_file&amp;gt;[^ ]+\.(?&amp;lt;source_type&amp;gt;\w+)) changed to (?&amp;lt;dest_path&amp;gt;.*)\\(?&amp;lt;dest_file&amp;gt;.+?\.(?&amp;lt;dest_type&amp;gt;\w+))$" | ...
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 25 Oct 2016 15:04:58 GMT</pubDate>
    <dc:creator>richgalloway</dc:creator>
    <dc:date>2016-10-25T15:04:58Z</dc:date>
    <item>
      <title>Regex Source and Destination files with path, filename, extension</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-Source-and-Destination-files-with-path-filename-extension/m-p/271989#M81850</link>
      <description>&lt;P&gt;I need some help with this one since it is beyond my regex skills which are not the best.  I would have used the field extractor but the data does not show up to extract.  The data comes from a tool called Varonis DatAlert and is stored in the Windows Event log and we want to be able to use this for custom Ransomware alerting.&lt;/P&gt;

&lt;P&gt;The field from the Windows Event log called &lt;STRONG&gt;Additional_Data&lt;/STRONG&gt; and I would like to extract it into 6 fields.&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Additional_Data Sample&lt;/STRONG&gt;&lt;BR /&gt;
I:\Dept3\folder1\folder two\folder 3\folder 4\Filename1.htm &lt;STRONG&gt;changed to&lt;/STRONG&gt; I:\Dept3\folder1\folder two\folder 3\folder 4\Filename1.txt&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Desired Fields&lt;/STRONG&gt;&lt;BR /&gt;
source_path = I:\Dept3\folder1\folder two\folder 3\folder 4&lt;BR /&gt;
source_file = Filename1.htm&lt;BR /&gt;
source_type = htm&lt;BR /&gt;
dest_path   = I:\Dept3\folder1\folder two\folder 3\folder 4&lt;BR /&gt;
dest_file       = Filename1.txt&lt;BR /&gt;
dest_type   = txt&lt;/P&gt;

&lt;P&gt;Thanks in advance&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 11:33:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-Source-and-Destination-files-with-path-filename-extension/m-p/271989#M81850</guid>
      <dc:creator>kent_farries</dc:creator>
      <dc:date>2020-09-29T11:33:02Z</dc:date>
    </item>
    <item>
      <title>Re: Regex Source and Destination files with path, filename, extension</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-Source-and-Destination-files-with-path-filename-extension/m-p/271990#M81851</link>
      <description>&lt;P&gt;It should be something like this if I'm not mistaken:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex field=Additional_Data  "^(?&amp;lt;source_path&amp;gt;.+?)\\\(?&amp;lt;source_file&amp;gt;[^\\\]+) changed to (?&amp;lt;dest_path&amp;gt;.+?)\\\(?&amp;lt;dest_file&amp;gt;[^\\\]+)$"
| rex field=source_file "\.(?&amp;lt;source_type&amp;gt;[^\.]+)$"
| rex field=dest_file "\.(?&amp;lt;dest_type&amp;gt;[^\.]+)$"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This is the way I tested it in my lab:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats count | fields - count
| eval Additional_Data ="I:\\Dept3\\folder1\\folder two\\folder 3\\folder 4\\Filename1.htm changed to I:\\Dept3\\folder1\\folder two\\folder 3\\folder 4\\Filename1.txt"
| rex field=Additional_Data  "^(?&amp;lt;source_path&amp;gt;.+?)\\\(?&amp;lt;source_file&amp;gt;[^\\\]+) changed to (?&amp;lt;dest_path&amp;gt;.+?)\\\(?&amp;lt;dest_file&amp;gt;[^\\\]+)$"
| rex field=source_file "\.(?&amp;lt;source_type&amp;gt;[^\.]+)$"
| rex field=dest_file "\.(?&amp;lt;dest_type&amp;gt;[^\.]+)$"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Output (see picture below):&lt;/P&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/2063i4791038C9E47E1E7/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Oct 2016 15:00:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-Source-and-Destination-files-with-path-filename-extension/m-p/271990#M81851</guid>
      <dc:creator>javiergn</dc:creator>
      <dc:date>2016-10-25T15:00:20Z</dc:date>
    </item>
    <item>
      <title>Re: Regex Source and Destination files with path, filename, extension</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-Source-and-Destination-files-with-path-filename-extension/m-p/271991#M81852</link>
      <description>&lt;P&gt;can you try below:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;yourBaseQuery
| rex field=Additional_Data "(?&amp;lt;source_path&amp;gt;.*\\)(?&amp;lt;sFileName&amp;gt;[^\.]+)\.(?&amp;lt;source_type&amp;gt;[^\s]+)\schanged\sto\s(?&amp;lt;dest_path&amp;gt;.*\\)(?&amp;lt;dFileName&amp;gt;[^\.]+)\.(?&amp;lt;dest_type&amp;gt;[^\s]+)"
| eval source_file=sFileName.".".source_type
|eval dest_file=dFileName.".".dest_type
| table Additional_Data, source_path, source_file, source_type, dest_path, dest_file, dest_type
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 25 Oct 2016 15:00:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-Source-and-Destination-files-with-path-filename-extension/m-p/271991#M81852</guid>
      <dc:creator>gokadroid</dc:creator>
      <dc:date>2016-10-25T15:00:27Z</dc:date>
    </item>
    <item>
      <title>Re: Regex Source and Destination files with path, filename, extension</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-Source-and-Destination-files-with-path-filename-extension/m-p/271992#M81853</link>
      <description>&lt;P&gt;This works with your sample data.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | rex field=Additional_Data "(?&amp;lt;source_path&amp;gt;.*?)\\(?&amp;lt;source_file&amp;gt;[^ ]+\.(?&amp;lt;source_type&amp;gt;\w+)) changed to (?&amp;lt;dest_path&amp;gt;.*)\\(?&amp;lt;dest_file&amp;gt;.+?\.(?&amp;lt;dest_type&amp;gt;\w+))$" | ...
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 25 Oct 2016 15:04:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-Source-and-Destination-files-with-path-filename-extension/m-p/271992#M81853</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2016-10-25T15:04:58Z</dc:date>
    </item>
    <item>
      <title>Re: Regex Source and Destination files with path, filename, extension</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-Source-and-Destination-files-with-path-filename-extension/m-p/271993#M81854</link>
      <description>&lt;P&gt;Since you want to extract this field from an existing field (Additional_Data), you'd have to to use Field Transforms. &lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/6.5.0/Knowledge/Createandmaintainsearch-timefieldextractionsthroughconfigurationfiles#Create_advanced_search-time_field_extractions_with_field_transforms"&gt;http://docs.splunk.com/Documentation/Splunk/6.5.0/Knowledge/Createandmaintainsearch-timefieldextractionsthroughconfigurationfiles#Create_advanced_search-time_field_extractions_with_field_transforms&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;May something like this would work&lt;/P&gt;

&lt;P&gt;props.conf (on Search Head)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[yourWinEventLogsourcetype]
REPORT-fromadditionaldata = additional_data_fields
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;transforms.conf (on Search Head)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[additional_data_fields]
SOURCE_KEY = Additional_Data
REGEX = (?&amp;lt;source_path&amp;gt;.+\\\(?&amp;lt;source_file&amp;gt;[^\.]+)\.(?&amp;lt;source_type&amp;gt;\S+)) changed to (?&amp;lt;dest_path&amp;gt;.+\\\(?&amp;lt;dest_file&amp;gt;[^\.]+)\.(?&amp;lt;dest_type&amp;gt;\S+)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 25 Oct 2016 15:06:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-Source-and-Destination-files-with-path-filename-extension/m-p/271993#M81854</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-10-25T15:06:38Z</dc:date>
    </item>
    <item>
      <title>Re: Regex Source and Destination files with path, filename, extension</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-Source-and-Destination-files-with-path-filename-extension/m-p/271994#M81855</link>
      <description>&lt;P&gt;Thank you so much for all the answers you guys are awesome.  &lt;/P&gt;

&lt;P&gt;I have one of them working right now and have tested a couple of the others but was not able to get them fully working yet.  I will go through all of them after work.  &lt;/P&gt;

&lt;P&gt;I do like the props and transforms as well but based on two of my tests it did not work yet and I'm probably doing something wrong.  I used them in my app on the search head but the fields did not show up and I have not tried to troubleshoot it yet.&lt;/P&gt;

&lt;P&gt;Once again, thanks!!!&lt;/P&gt;</description>
      <pubDate>Tue, 25 Oct 2016 21:45:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-Source-and-Destination-files-with-path-filename-extension/m-p/271994#M81855</guid>
      <dc:creator>kent_farries</dc:creator>
      <dc:date>2016-10-25T21:45:45Z</dc:date>
    </item>
    <item>
      <title>Re: Regex Source and Destination files with path, filename, extension</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-Source-and-Destination-files-with-path-filename-extension/m-p/271995#M81856</link>
      <description>&lt;P&gt;Thanks worked first try.&lt;/P&gt;</description>
      <pubDate>Tue, 25 Oct 2016 21:46:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-Source-and-Destination-files-with-path-filename-extension/m-p/271995#M81856</guid>
      <dc:creator>kent_farries</dc:creator>
      <dc:date>2016-10-25T21:46:04Z</dc:date>
    </item>
  </channel>
</rss>

