<?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: Need help in append in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Need-help-in-append/m-p/542546#M153693</link>
    <description>&lt;P&gt;Use inputlookup (to get current contents) before outputlookup (to write full set)&lt;/P&gt;</description>
    <pubDate>Fri, 05 Mar 2021 12:32:31 GMT</pubDate>
    <dc:creator>ITWhisperer</dc:creator>
    <dc:date>2021-03-05T12:32:31Z</dc:date>
    <item>
      <title>Need help in append</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-in-append/m-p/542483#M153668</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am facing an issue in appending an query. Here my objective is to update the kv store with the list of servers, alert_flag(if the alert has been raised) and count(number of times the server has created an event). Below is the query that I have used.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;index= index&lt;BR /&gt;&lt;/STRONG&gt;&lt;STRONG&gt;| lookup source_host_kvstore_001 source_host OUTPUT source_host as temp_source_host count alert_flag| dedup source_host&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;| eval count=if(isnull(count),0,count)| eval count = count+1&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;| eval alert_flag = if(isnull(alert_flag),0,if((alert_flag=1),1,0))&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;| eval _time=now()&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;| table _time source_host alert_flag count | sort -_time&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;| outputlookup source_host_kvstore_001 append=true&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;When the above is ran everytime the same host is updated and also added in the new row, however, I need a single update of the count and alert_flag for a host. The data is pushed to the kv store as below by a new increase in the count.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;_time&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;alert_flag&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; count&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;source_host&lt;BR /&gt;2021-03-05 13:01:50&amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Server 1&lt;BR /&gt;2021-03-05 13:01:50&amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Server 2&lt;BR /&gt;2021-03-05 13:01:50&amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Server 3&lt;BR /&gt;2021-03-05 13:01:53&amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Server 1&lt;BR /&gt;2021-03-05 13:01:53&amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Server 2&lt;BR /&gt;2021-03-05 13:01:53&amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Server 3&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, I am looking for the data to be updated in the KV store like below.&lt;/P&gt;&lt;P&gt;_time&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;alert_flag&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; count&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;source_host&lt;BR /&gt;2021-03-05 13:01:53&amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Server 1&lt;BR /&gt;2021-03-05 13:01:53&amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Server 2&lt;BR /&gt;2021-03-05 13:01:53&amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Server 3&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please guide me through this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;</description>
      <pubDate>Fri, 05 Mar 2021 08:02:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-in-append/m-p/542483#M153668</guid>
      <dc:creator>srinivasgowda</dc:creator>
      <dc:date>2021-03-05T08:02:06Z</dc:date>
    </item>
    <item>
      <title>Re: Need help in append</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-in-append/m-p/542497#M153676</link>
      <description>&lt;P&gt;hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/231485"&gt;@srinivasgowda&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Use stats with latest function to get latest values by source_host.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index= index
| lookup source_host_kvstore_001 source_host OUTPUT source_host as temp_source_host count alert_flag
| eval count=if(isnull(count),1,count+1)
| eval alert_flag = if(isnull(alert_flag),0,if((alert_flag=1),1,0))
| eval _time=now()
| fields _time source_host alert_flag count 
| stats latest(_time) as _time latest(*) as * by source_host
| outputlookup source_host_kvstore_001 append=true&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 05 Mar 2021 08:28:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-in-append/m-p/542497#M153676</guid>
      <dc:creator>manjunathmeti</dc:creator>
      <dc:date>2021-03-05T08:28:26Z</dc:date>
    </item>
    <item>
      <title>Re: Need help in append</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-in-append/m-p/542501#M153677</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/129090"&gt;@manjunathmeti&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;Thanks for the quick response. This is still giving the same result by adding new rows for the same source_host in the kvstore. I am looking to have a singe row for each source_host and just the count to increase everytime there is an event from the source_host.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;</description>
      <pubDate>Fri, 05 Mar 2021 08:35:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-in-append/m-p/542501#M153677</guid>
      <dc:creator>srinivasgowda</dc:creator>
      <dc:date>2021-03-05T08:35:28Z</dc:date>
    </item>
    <item>
      <title>Re: Need help in append</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-in-append/m-p/542503#M153678</link>
      <description>&lt;P&gt;You need to use append=false&lt;/P&gt;</description>
      <pubDate>Fri, 05 Mar 2021 08:36:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-in-append/m-p/542503#M153678</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2021-03-05T08:36:21Z</dc:date>
    </item>
    <item>
      <title>Re: Need help in append</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-in-append/m-p/542535#M153686</link>
      <description>&lt;P&gt;This will update the count for the source_host, however, if a new source_host come in then the existing data in the kvstore would be deleted.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Mar 2021 11:05:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-in-append/m-p/542535#M153686</guid>
      <dc:creator>srinivasgowda</dc:creator>
      <dc:date>2021-03-05T11:05:59Z</dc:date>
    </item>
    <item>
      <title>Re: Need help in append</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-in-append/m-p/542537#M153687</link>
      <description>&lt;P&gt;Can you append / union the current contents of the store so your search includes everything you want before you output it?&lt;/P&gt;</description>
      <pubDate>Fri, 05 Mar 2021 11:16:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-in-append/m-p/542537#M153687</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2021-03-05T11:16:24Z</dc:date>
    </item>
    <item>
      <title>Re: Need help in append</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-in-append/m-p/542538#M153688</link>
      <description>&lt;P&gt;Yes, append=false works as long as the same set of source_host is repeated in every run, but if in a run there is events from just 1 source_host then the remaining in the kvstore would be deleted updating just the one that was currently present.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Mar 2021 11:19:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-in-append/m-p/542538#M153688</guid>
      <dc:creator>srinivasgowda</dc:creator>
      <dc:date>2021-03-05T11:19:42Z</dc:date>
    </item>
    <item>
      <title>Re: Need help in append</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-in-append/m-p/542541#M153690</link>
      <description>&lt;P&gt;Exactly, so use inputlookup as part of the search to append or union the current contents of the keystore&lt;/P&gt;</description>
      <pubDate>Fri, 05 Mar 2021 11:35:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-in-append/m-p/542541#M153690</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2021-03-05T11:35:21Z</dc:date>
    </item>
    <item>
      <title>Re: Need help in append</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-in-append/m-p/542542#M153691</link>
      <description>&lt;P&gt;inputlookup does not work after using outputlookup.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Mar 2021 11:40:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-in-append/m-p/542542#M153691</guid>
      <dc:creator>srinivasgowda</dc:creator>
      <dc:date>2021-03-05T11:40:41Z</dc:date>
    </item>
    <item>
      <title>Re: Need help in append</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-in-append/m-p/542546#M153693</link>
      <description>&lt;P&gt;Use inputlookup (to get current contents) before outputlookup (to write full set)&lt;/P&gt;</description>
      <pubDate>Fri, 05 Mar 2021 12:32:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-in-append/m-p/542546#M153693</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2021-03-05T12:32:31Z</dc:date>
    </item>
  </channel>
</rss>

