<?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 to update a lookup with a scheduled search by appending new data or editing existing rows, not replace the entire lookup? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-to-update-a-lookup-with-a-scheduled-search-by-appending-new/m-p/220415#M43310</link>
    <description>&lt;P&gt;Hi Cuyose,&lt;/P&gt;

&lt;P&gt;Yes, you can do such a thing in Splunk. Here is an example that will add all hosts found within the last last hour into a lookup file:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal earliest=-1h 
| eval server_name=host 
| table server_name 
| append [ inputcsv server_down ] 
| dedup server_name 
| outputcsv server_down
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The second example uses the same lookup file and removes all hosts found in the events within the last and the lookup file:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal earliest=-1h 
| eval server_name=host 
| table server_name 
| append [ inputcsv server_down ] 
| stats count by server_name 
| eval server_name=case(count = 2,null() , count=1,server_name) 
| table server_name 
| outputcsv server_down
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;To test it and to verify use the first search and use the 2nd line as &lt;CODE&gt;| eval server_name="foo"&lt;/CODE&gt; to add some dummy hosts.&lt;/P&gt;

&lt;P&gt;Hope this helps ...&lt;/P&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
    <pubDate>Tue, 09 Aug 2016 20:21:23 GMT</pubDate>
    <dc:creator>MuS</dc:creator>
    <dc:date>2016-08-09T20:21:23Z</dc:date>
    <item>
      <title>How to update a lookup with a scheduled search by appending new data or editing existing rows, not replace the entire lookup?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-update-a-lookup-with-a-scheduled-search-by-appending-new/m-p/220414#M43309</link>
      <description>&lt;P&gt;I can't seem to find this scenario which is odd. Basically I want to update a list of usernames. I want to run an initial search over a time frame to create the initial lookup. I then want to run a scheduled search to update this lookup, either by appending new data or editing the existing rows in the lookup based on a column being the primary key (userid).&lt;/P&gt;

&lt;P&gt;I DO NOT WANT the entire CSV replaced, or duplicate userid's, which seems to be what all the documentation says.  Does Splunk support this?&lt;/P&gt;</description>
      <pubDate>Tue, 09 Aug 2016 19:59:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-update-a-lookup-with-a-scheduled-search-by-appending-new/m-p/220414#M43309</guid>
      <dc:creator>Cuyose</dc:creator>
      <dc:date>2016-08-09T19:59:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to update a lookup with a scheduled search by appending new data or editing existing rows, not replace the entire lookup?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-update-a-lookup-with-a-scheduled-search-by-appending-new/m-p/220415#M43310</link>
      <description>&lt;P&gt;Hi Cuyose,&lt;/P&gt;

&lt;P&gt;Yes, you can do such a thing in Splunk. Here is an example that will add all hosts found within the last last hour into a lookup file:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal earliest=-1h 
| eval server_name=host 
| table server_name 
| append [ inputcsv server_down ] 
| dedup server_name 
| outputcsv server_down
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The second example uses the same lookup file and removes all hosts found in the events within the last and the lookup file:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal earliest=-1h 
| eval server_name=host 
| table server_name 
| append [ inputcsv server_down ] 
| stats count by server_name 
| eval server_name=case(count = 2,null() , count=1,server_name) 
| table server_name 
| outputcsv server_down
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;To test it and to verify use the first search and use the 2nd line as &lt;CODE&gt;| eval server_name="foo"&lt;/CODE&gt; to add some dummy hosts.&lt;/P&gt;

&lt;P&gt;Hope this helps ...&lt;/P&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
      <pubDate>Tue, 09 Aug 2016 20:21:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-update-a-lookup-with-a-scheduled-search-by-appending-new/m-p/220415#M43310</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2016-08-09T20:21:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to update a lookup with a scheduled search by appending new data or editing existing rows, not replace the entire lookup?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-update-a-lookup-with-a-scheduled-search-by-appending-new/m-p/220416#M43311</link>
      <description>&lt;P&gt;I took a slightly different route.  I think this should work. Testing now, but would like any input, it seems it might be able to be optimized.&lt;/P&gt;

&lt;P&gt;abc.csv generated by &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;base search
| stats  latest(_time) as UPDATED by LOGIN LOCATION LOCATIONCOUNTRY VENDOR ROLE TYPE SUPERVISOR 
| convert ctime(UPDATED)
| table  UPDATED LOGIN LOCATION LOCATIONCOUNTRY VENDOR ROLE TYPE SUPERVISOR
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Update (scheduled search)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;inputlookup abc.csv
|append [search {base search}
|stats  latest(_time) as UPDATED by LOGIN LOCATION LOCATIONCOUNTRY VENDOR ROLE TYPE SUPERVISOR | convert ctime(UPDATED)| table  UPDATED LOGIN LOCATION LOCATIONCOUNTRY VENDOR ROLE TYPE SUPERVISOR]
|stats latest(UPDATED) as UPDATED by LOGIN LOCATION LOCATIONCOUNTRY VENDOR ROLE TYPE SUPERVISOR
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So basically this is running a subsearch and adding all those rows to the current lookup csv which has an "updated" column.  It then compares the UPDATED with "latests" to get rid of the duplicates.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Aug 2016 20:39:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-update-a-lookup-with-a-scheduled-search-by-appending-new/m-p/220416#M43311</guid>
      <dc:creator>Cuyose</dc:creator>
      <dc:date>2016-08-09T20:39:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to update a lookup with a scheduled search by appending new data or editing existing rows, not replace the entire lookup?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-update-a-lookup-with-a-scheduled-search-by-appending-new/m-p/220417#M43312</link>
      <description>&lt;P&gt;Nice - just be aware off the sub search limits &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.4.2/Search/Aboutsubsearches#Subsearch_performance"&gt;http://docs.splunk.com/Documentation/Splunk/6.4.2/Search/Aboutsubsearches#Subsearch_performance&lt;/A&gt; &lt;BR /&gt;
But as long as you don't come close those limits and are happy with the performance, use it &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Aug 2016 20:51:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-update-a-lookup-with-a-scheduled-search-by-appending-new/m-p/220417#M43312</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2016-08-09T20:51:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to update a lookup with a scheduled search by appending new data or editing existing rows, not replace the entire lookup?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-update-a-lookup-with-a-scheduled-search-by-appending-new/m-p/220418#M43313</link>
      <description>&lt;P&gt;Since the subsearch is going to be run on a much more limited time frame I will be good.  &lt;/P&gt;

&lt;P&gt;The issue I am currently having is that I can't re-write the UPDATED value back after doing the latest(UPDATED) to filter out the dupes.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Aug 2016 20:57:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-update-a-lookup-with-a-scheduled-search-by-appending-new/m-p/220418#M43313</guid>
      <dc:creator>Cuyose</dc:creator>
      <dc:date>2016-08-09T20:57:50Z</dc:date>
    </item>
  </channel>
</rss>

