<?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 update a lookup table using a scheduled search by appending results, not replace the old data? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-update-a-lookup-table-using-a-scheduled-search-by/m-p/115909#M30756</link>
    <description>&lt;P&gt;Hi,&lt;BR /&gt;
I have one scheduled search which saves the output in a file "filename.csv" at specific interval of time.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="myindex"|........|.....|outputlookup filename.csv
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But what is happening now is that the complete file content is replaced with the new one, hence losing the old data from the file. I want to append the search result to the data already present in filename.csv&lt;/P&gt;

&lt;P&gt;Please Help...!!!&lt;/P&gt;</description>
    <pubDate>Thu, 21 May 2015 06:38:40 GMT</pubDate>
    <dc:creator>harshal_chakran</dc:creator>
    <dc:date>2015-05-21T06:38:40Z</dc:date>
    <item>
      <title>How to update a lookup table using a scheduled search by appending results, not replace the old data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-update-a-lookup-table-using-a-scheduled-search-by/m-p/115909#M30756</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;
I have one scheduled search which saves the output in a file "filename.csv" at specific interval of time.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="myindex"|........|.....|outputlookup filename.csv
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But what is happening now is that the complete file content is replaced with the new one, hence losing the old data from the file. I want to append the search result to the data already present in filename.csv&lt;/P&gt;

&lt;P&gt;Please Help...!!!&lt;/P&gt;</description>
      <pubDate>Thu, 21 May 2015 06:38:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-update-a-lookup-table-using-a-scheduled-search-by/m-p/115909#M30756</guid>
      <dc:creator>harshal_chakran</dc:creator>
      <dc:date>2015-05-21T06:38:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to update a lookup table using a scheduled search by appending results, not replace the old data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-update-a-lookup-table-using-a-scheduled-search-by/m-p/115910#M30757</link>
      <description>&lt;P&gt;You can try something like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|inputlookup filename.csv | append [your new search] | filter the duplicate events if required | outputlookup filename.csv
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks!!&lt;/P&gt;</description>
      <pubDate>Thu, 21 May 2015 06:43:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-update-a-lookup-table-using-a-scheduled-search-by/m-p/115910#M30757</guid>
      <dc:creator>vganjare</dc:creator>
      <dc:date>2015-05-21T06:43:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to update a lookup table using a scheduled search by appending results, not replace the old data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-update-a-lookup-table-using-a-scheduled-search-by/m-p/115911#M30758</link>
      <description>&lt;P&gt;As vganjare mentions it would be handy to get an idea of what you are doing with your lookup. At any rate I think what you are looking for is when you do a | lookup somefile.csv you need to put append=true. As an example here is the first of 2 queries used to track systems that stop sending logs. This one tracks the last time a host sent in logs (runs every 4 hrs) and others run every 8 and run a check against the last_seen field. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=foo | eval host=lower(host) | rex field=host "(?&amp;lt;host&amp;gt;(^[^0-9]\S[^\.]+)|(^[0-9]\S+))" | stats max(_time) AS last_seen by host | inputlookup append=T hosts_list.csv | stats max(last_seen) AS last_seen by host | eval right_now = now() | eval time_diff = right_now - last_seen | where time_diff &amp;lt; (86400 * 3) |  table host last_seen | outputlookup hosts_list.csv
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Relative to your question I'm getting results from a query, adding those results to the csv, manipulating the results, and then writing the results back to the csv. The 2 almost back to back stats commands are because once you've appended the results to the existing csv most systems will have 2 lines and I'm only interested in keeping the latest.&lt;/P&gt;

&lt;P&gt;BTW I do this as a csv because if a system is decommissioned I can simply remove it from the list.&lt;/P&gt;</description>
      <pubDate>Thu, 21 May 2015 11:37:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-update-a-lookup-table-using-a-scheduled-search-by/m-p/115911#M30758</guid>
      <dc:creator>Runals</dc:creator>
      <dc:date>2015-05-21T11:37:29Z</dc:date>
    </item>
  </channel>
</rss>

