<?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 How to write a search to only show the latest contents of a lookup file on a dashboard? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-to-only-show-the-latest-contents-of-a/m-p/253641#M75927</link>
    <description>&lt;P&gt;Hi there,&lt;/P&gt;

&lt;P&gt;My external program is retrieving the data and creating lookup table every night. The files are stored like below.&lt;BR /&gt;
&lt;CODE&gt;$SPLUNK_HOME/etc/apps/MyApp/lookups/FILE_YYYYmmdd&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;The thing is I have to check the lookup table manually and give the list to my colleague every time since they don't know SPL at all.&lt;BR /&gt;
Is there any good SPL to display only the latest contents of lookup flle on dashboard?&lt;/P&gt;

&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
    <pubDate>Tue, 01 Dec 2015 07:07:04 GMT</pubDate>
    <dc:creator>kuga_mbsd</dc:creator>
    <dc:date>2015-12-01T07:07:04Z</dc:date>
    <item>
      <title>How to write a search to only show the latest contents of a lookup file on a dashboard?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-to-only-show-the-latest-contents-of-a/m-p/253641#M75927</link>
      <description>&lt;P&gt;Hi there,&lt;/P&gt;

&lt;P&gt;My external program is retrieving the data and creating lookup table every night. The files are stored like below.&lt;BR /&gt;
&lt;CODE&gt;$SPLUNK_HOME/etc/apps/MyApp/lookups/FILE_YYYYmmdd&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;The thing is I have to check the lookup table manually and give the list to my colleague every time since they don't know SPL at all.&lt;BR /&gt;
Is there any good SPL to display only the latest contents of lookup flle on dashboard?&lt;/P&gt;

&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Dec 2015 07:07:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-to-only-show-the-latest-contents-of-a/m-p/253641#M75927</guid>
      <dc:creator>kuga_mbsd</dc:creator>
      <dc:date>2015-12-01T07:07:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a search to only show the latest contents of a lookup file on a dashboard?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-to-only-show-the-latest-contents-of-a/m-p/253642#M75928</link>
      <description>&lt;P&gt;Have you considered rotating the "old" lookup files instead? By this you wouldn't have to check a new lookup file every day.&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;Copy lookup.csv file to lookup_current_date.csv&lt;/LI&gt;
&lt;LI&gt;Overwrite lookup.csv&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;You don't have to change anything in the SPL or in your dahsboards this way.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 08:01:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-to-only-show-the-latest-contents-of-a/m-p/253642#M75928</guid>
      <dc:creator>DMohn</dc:creator>
      <dc:date>2020-09-29T08:01:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a search to only show the latest contents of a lookup file on a dashboard?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-to-only-show-the-latest-contents-of-a/m-p/253643#M75929</link>
      <description>&lt;P&gt;Thank you very much for your reply, DMohn.&lt;/P&gt;

&lt;P&gt;I think your idea sounds good, however, I'm afraid that it doesnt work for my case because I need to keep the date of file creation at the file name for the records.&lt;/P&gt;

&lt;P&gt;Please advise.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Dec 2015 09:07:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-to-only-show-the-latest-contents-of-a/m-p/253643#M75929</guid>
      <dc:creator>kuga_mbsd</dc:creator>
      <dc:date>2015-12-01T09:07:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a search to only show the latest contents of a lookup file on a dashboard?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-to-only-show-the-latest-contents-of-a/m-p/253644#M75930</link>
      <description>&lt;P&gt;Is the file name "for the records" needed within the lookup as well?&lt;/P&gt;

&lt;P&gt;Otherwise you could go for creating two files with your external data source: the lookup.csv which will be used by Splunk dashboard, and a FILE_YYYYmmdd, as you do currently. Furthermore, you could use a small script, which lists the contents of your lookup directory, splunk the results, and display the latest file name on your dashboard for reference.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Dec 2015 10:51:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-to-only-show-the-latest-contents-of-a/m-p/253644#M75930</guid>
      <dc:creator>DMohn</dc:creator>
      <dc:date>2015-12-01T10:51:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a search to only show the latest contents of a lookup file on a dashboard?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-to-only-show-the-latest-contents-of-a/m-p/253645#M75931</link>
      <description>&lt;P&gt;well... yes, I was thinking exact your suggestions, to create two files or make script.&lt;BR /&gt;
I was wondering if I could make it by SPL, but it seems undoable...&lt;/P&gt;

&lt;P&gt;Anyway, thanks a lot, DMohn!&lt;/P&gt;</description>
      <pubDate>Wed, 02 Dec 2015 00:30:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-to-only-show-the-latest-contents-of-a/m-p/253645#M75931</guid>
      <dc:creator>kuga_mbsd</dc:creator>
      <dc:date>2015-12-02T00:30:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a search to only show the latest contents of a lookup file on a dashboard?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-to-only-show-the-latest-contents-of-a/m-p/253646#M75932</link>
      <description>&lt;P&gt;SPL can do it easy. &lt;/P&gt;

&lt;P&gt;2 ways. You can either have it copy the data OR have the macro fill in the name based on an eval.&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;You will have both the old with old filename and also a newer one that can always be accessed with the same name/definition.&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;Just do an&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;inputlookup `latest_lookup_file` | outputlookup latestlookup
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;"latest_lookup_file" is macro that will figure out the file format that you specified automatically.&lt;BR /&gt;
latestlookup should be a definition pointing to another csv file that users will always access.&lt;/P&gt;

&lt;P&gt;ie. macros.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[latest_lookup_file]
definition = lower(strftime(relative_time(time(), "@d"), "FILE_%Y%m%d.csv"))
iseval = 1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now schedule that inputlookup line as a savedsearch that is run some time after the your file is scheduled to be uploaded.&lt;/P&gt;

&lt;P&gt;or 2. Use the macro from above and just call it directly.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;inputlookup `latest_lookup_file`
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;That will automatically find the latest file. There won't be a copy but all your old ones will be there. The downside to this is that if your script doesn't run anything that uses this macro will fail the next day. Method 1 is safest.&lt;/P&gt;

&lt;P&gt;Enjoy!&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 08:03:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-to-only-show-the-latest-contents-of-a/m-p/253646#M75932</guid>
      <dc:creator>Lucas_K</dc:creator>
      <dc:date>2020-09-29T08:03:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a search to only show the latest contents of a lookup file on a dashboard?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-to-only-show-the-latest-contents-of-a/m-p/253647#M75933</link>
      <description>&lt;P&gt;Thank you for your comment, Lucas.&lt;/P&gt;

&lt;P&gt;Seems like it is doable with using macros.conf!&lt;BR /&gt;
I've never configured this file but worth to try.&lt;/P&gt;

&lt;P&gt;Thanks a bunch!!&lt;/P&gt;</description>
      <pubDate>Wed, 02 Dec 2015 04:00:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-to-only-show-the-latest-contents-of-a/m-p/253647#M75933</guid>
      <dc:creator>kuga_mbsd</dc:creator>
      <dc:date>2015-12-02T04:00:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a search to only show the latest contents of a lookup file on a dashboard?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-to-only-show-the-latest-contents-of-a/m-p/253648#M75934</link>
      <description>&lt;P&gt;That's really clever! I love that you're using strftime to generate the filename &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 10 Apr 2016 22:26:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-to-only-show-the-latest-contents-of-a/m-p/253648#M75934</guid>
      <dc:creator>joxley</dc:creator>
      <dc:date>2016-04-10T22:26:19Z</dc:date>
    </item>
  </channel>
</rss>

