<?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: How filter by source name and keep only the last version in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-filter-by-source-name-and-keep-only-the-last-version/m-p/259226#M49762</link>
    <description>&lt;P&gt;Please add your responses as a comment to asnwers and not as a new answer. Gets confusing &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; Sometimes, when the code block is not used correctly, certain special chars are not displayed correctly in the answer. That's the reason you are seeing '(?.)_(?.)'&lt;/P&gt;

&lt;P&gt;If you look at my answer below, you should see field name for each segment, which is what was missing earlier&lt;/P&gt;</description>
    <pubDate>Tue, 19 Jul 2016 16:11:09 GMT</pubDate>
    <dc:creator>sundareshr</dc:creator>
    <dc:date>2016-07-19T16:11:09Z</dc:date>
    <item>
      <title>How filter by source name and keep only the last version</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-filter-by-source-name-and-keep-only-the-last-version/m-p/259220#M49756</link>
      <description>&lt;P&gt;We use splunk to generate reports and provide them to an external application (Tableau). The data source are csv file using the following naming standard:&lt;/P&gt;

&lt;P&gt;tableau_idwallet_workdate_iddollaru.csv&lt;/P&gt;

&lt;P&gt;idwallet=A unique identification number of a customer portfolio&lt;BR /&gt;
workdate=A processing date&lt;BR /&gt;
iddollaru=A session number that increases with each generation of csv&lt;/P&gt;

&lt;P&gt;Most often we have to provide a report that returns all provided with simple queries:&lt;BR /&gt;
index = idx_ofi_tableau_rec | fields - _raw, _span, sourcetype, indexes, source, splunk_server, splunk_server_group&lt;/P&gt;

&lt;P&gt;But sometimes trades change a value in their tool and generates a new csv with the same identifier idwallet and the same workdate. Only iddollaru changes and increments.&lt;/P&gt;

&lt;P&gt;It is then that we generate a splunk report that contains all the datas but only csv updated with iddollaru most recent for the same idwallet and the same workdate.&lt;/P&gt;

&lt;P&gt;I try this &lt;BR /&gt;
index=idx_ofi_tableau_rec | eval id_trt = idwallet."-".workdate | stats first(*) by id_trt&lt;/P&gt;

&lt;P&gt;but it doesn't work. Also I must not change the name of the field (With first, the field rename "first(field)"&lt;/P&gt;

&lt;P&gt;Can you help me ? Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 10:13:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-filter-by-source-name-and-keep-only-the-last-version/m-p/259220#M49756</guid>
      <dc:creator>bvivi57</dc:creator>
      <dc:date>2020-09-29T10:13:41Z</dc:date>
    </item>
    <item>
      <title>Re: How filter by source name and keep only the last version</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-filter-by-source-name-and-keep-only-the-last-version/m-p/259221#M49757</link>
      <description>&lt;P&gt;Try either of these approaches...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=idx_ofi_tableau_rec | rex field=source "_(?&amp;lt;dt&amp;gt;[^\_\.]+)\." | eventstats max(dt) as current | where current=dt
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;*&lt;STRONG&gt;&lt;EM&gt;OR&lt;/EM&gt;&lt;/STRONG&gt;*&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=idx_ofi_tableau_rec | eval idxtime=_indextime | eventstats max(idxtime) as current | where current=idxtime
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 13 Jul 2016 18:34:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-filter-by-source-name-and-keep-only-the-last-version/m-p/259221#M49757</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-07-13T18:34:44Z</dc:date>
    </item>
    <item>
      <title>Re: How filter by source name and keep only the last version</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-filter-by-source-name-and-keep-only-the-last-version/m-p/259222#M49758</link>
      <description>&lt;P&gt;Another option (will pickup the latest available source/file data)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index = idx_ofi_tableau_rec [| tstats latest(source) as source WHERE index = idx_ofi_tableau_rec ]| fields - _raw, _span, sourcetype, indexes, source, splunk_server, splunk_server_group
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 13 Jul 2016 19:05:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-filter-by-source-name-and-keep-only-the-last-version/m-p/259222#M49758</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-07-13T19:05:16Z</dc:date>
    </item>
    <item>
      <title>Re: How filter by source name and keep only the last version</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-filter-by-source-name-and-keep-only-the-last-version/m-p/259223#M49759</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;
Thanks for your respond and your help. &lt;BR /&gt;
Excuse me for the delay in my response.&lt;/P&gt;

&lt;P&gt;I work with three test files&lt;/P&gt;

&lt;P&gt;File A : Tableau_139815_20160708_0389564&lt;BR /&gt;
File B : Tableau_139815_20160708_0389565&lt;BR /&gt;
File C : Tableau_139815_20160712_0389566&lt;/P&gt;

&lt;P&gt;The query should return only the file contents B and C&lt;/P&gt;

&lt;P&gt;With &lt;BR /&gt;
     index=idx_ofi_tableau_rec | rex field=source "&lt;EM&gt;(?&lt;DL&gt;&lt;DT&gt;[^\.]+)." | eventstats max(dt) as current | where current=dt&lt;BR /&gt;
Only C content is found&lt;BR /&gt;
Same result with&lt;BR /&gt;
     index=idx_ofi_tableau_rec | eval idxtime=_indextime | eventstats max(idxtime) as current | where current=idxtime&lt;/DT&gt;&lt;/DL&gt;&lt;/EM&gt;&lt;/P&gt;

&lt;P&gt;Same for the last requests.&lt;BR /&gt;
index = idx_ofi_tableau_rec [| tstats latest(source) as source WHERE index = idx_ofi_tableau_rec ]| fields - _raw, _span, sourcetype, indexes, source, splunk_server, splunk_server_group&lt;/P&gt;

&lt;P&gt;I continued searching...&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 10:16:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-filter-by-source-name-and-keep-only-the-last-version/m-p/259223#M49759</guid>
      <dc:creator>bvivi57</dc:creator>
      <dc:date>2020-09-29T10:16:36Z</dc:date>
    </item>
    <item>
      <title>Re: How filter by source name and keep only the last version</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-filter-by-source-name-and-keep-only-the-last-version/m-p/259224#M49760</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=idx_ofi_tableau_rec | rex field=source "(?&amp;lt;base&amp;gt;.*)_(?&amp;lt;dt&amp;gt;.*)" | eventstats max(dt) as current by base | where current=dt
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 19 Jul 2016 13:42:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-filter-by-source-name-and-keep-only-the-last-version/m-p/259224#M49760</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-07-19T13:42:58Z</dc:date>
    </item>
    <item>
      <title>Re: How filter by source name and keep only the last version</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-filter-by-source-name-and-keep-only-the-last-version/m-p/259225#M49761</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;

&lt;P&gt;With this request, we have this error:&lt;/P&gt;

&lt;P&gt;"Error in 'rex' command: Encountered the following error while compiling the regex '(?.)_(?.)': Regex: unrecognized character after (? or (?- "&lt;/P&gt;

&lt;P&gt;Is it normal to have no  in the regex queries ?&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jul 2016 14:33:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-filter-by-source-name-and-keep-only-the-last-version/m-p/259225#M49761</guid>
      <dc:creator>bvivi57</dc:creator>
      <dc:date>2016-07-19T14:33:17Z</dc:date>
    </item>
    <item>
      <title>Re: How filter by source name and keep only the last version</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-filter-by-source-name-and-keep-only-the-last-version/m-p/259226#M49762</link>
      <description>&lt;P&gt;Please add your responses as a comment to asnwers and not as a new answer. Gets confusing &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; Sometimes, when the code block is not used correctly, certain special chars are not displayed correctly in the answer. That's the reason you are seeing '(?.)_(?.)'&lt;/P&gt;

&lt;P&gt;If you look at my answer below, you should see field name for each segment, which is what was missing earlier&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jul 2016 16:11:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-filter-by-source-name-and-keep-only-the-last-version/m-p/259226#M49762</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-07-19T16:11:09Z</dc:date>
    </item>
    <item>
      <title>Re: How filter by source name and keep only the last version</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-filter-by-source-name-and-keep-only-the-last-version/m-p/259227#M49763</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;
Sorry for my error when I use "New Answer"&lt;/P&gt;

&lt;P&gt;Ans thank you for your help ! Your request is OK !!!! &lt;/P&gt;</description>
      <pubDate>Mon, 25 Jul 2016 15:58:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-filter-by-source-name-and-keep-only-the-last-version/m-p/259227#M49763</guid>
      <dc:creator>bvivi57</dc:creator>
      <dc:date>2016-07-25T15:58:52Z</dc:date>
    </item>
  </channel>
</rss>

