<?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: Conditional Outputlookup - dont write when no results in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Why-do-daily-outputlookup-searches-have-zero-results-and-leave/m-p/599147#M208588</link>
    <description>&lt;P&gt;Always consider creating an ideas post if you see something you want.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://ideas.splunk.com/ideas/EID-I-1474" target="_blank"&gt;https://ideas.splunk.com/ideas/EID-I-1474&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 24 May 2022 17:54:25 GMT</pubDate>
    <dc:creator>twollenslegel_s</dc:creator>
    <dc:date>2022-05-24T17:54:25Z</dc:date>
    <item>
      <title>Why do daily outputlookup searches have zero results and leave an empty lookup file?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-do-daily-outputlookup-searches-have-zero-results-and-leave/m-p/44977#M10619</link>
      <description>&lt;P&gt;We often create daily lookups from our search results, which are then used for several other key searches. On occasion, upstream processes fail and data that we index into splunk comes in late for whatever reason or doesnt come in at all. The problem is that if our daily outputlookup searches run and pick up zero results they wipe out the lookup file completely and leave us with an empty lookup file.&lt;/P&gt;
&lt;P&gt;Looking to do something along these lines:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;if event count is less than xxx, then do nothing, 
else
write outputlookup
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I am open to other suggestions also to get around this issue. I dont want to append and if the results do come in then I do need to lose the results in the file from the previous day.&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 24 May 2022 18:41:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-do-daily-outputlookup-searches-have-zero-results-and-leave/m-p/44977#M10619</guid>
      <dc:creator>pj</dc:creator>
      <dc:date>2022-05-24T18:41:02Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Outputlookup - dont write when no results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-do-daily-outputlookup-searches-have-zero-results-and-leave/m-p/44978#M10620</link>
      <description>&lt;P&gt;This will do it, but it necessitates running your search twice:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Your Search Here That Creates "count" | addinfo | eval info_max_time=if((count&amp;lt;xxx), 0, info_max_time) | map search="search earliest=$info_min_time$ latest=$info_max_time$ Your Search Here That Creates "count" | outputlookup SomeFile.csv"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What happens is that passing in &lt;CODE&gt;0&lt;/CODE&gt; for &lt;CODE&gt;latest&lt;/CODE&gt; causes the search to crash before it gets to the &lt;CODE&gt;outputlookup&lt;/CODE&gt; command when &lt;CODE&gt;count &amp;lt; xxx&lt;/CODE&gt;.&lt;/P&gt;</description>
      <pubDate>Sat, 27 Jun 2015 03:45:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-do-daily-outputlookup-searches-have-zero-results-and-leave/m-p/44978#M10620</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-06-27T03:45:53Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Outputlookup - dont write when no results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-do-daily-outputlookup-searches-have-zero-results-and-leave/m-p/44979#M10621</link>
      <description>&lt;P&gt;From Splunk 7.1.x , there is a parameter called &lt;CODE&gt;override_if_empty&lt;/CODE&gt; which does exactly the same (but only when it is empty)&lt;/P&gt;

&lt;P&gt;For Previous version 6.x etc. what I have done is two level steps (&lt;STRONG&gt;You could do in one single step if your search is simple&lt;/STRONG&gt;). Let's say your old csv  is called &lt;CODE&gt;my_original.csv&lt;/CODE&gt;&lt;BR /&gt;
1. Write the outputlookup csv based on current data. Call this by another name  &lt;CODE&gt;my_temp.csv&lt;/CODE&gt;&lt;BR /&gt;
2. Do an append condition and check for valid records on &lt;CODE&gt;my_temp.csv&lt;/CODE&gt;. If not valid, use the &lt;CODE&gt;my_original.csv&lt;/CODE&gt;. &lt;/P&gt;

&lt;P&gt;Below is an example for checking if there are more than 5 records within the &lt;CODE&gt;my_temp.csv&lt;/CODE&gt;, otherwise use existing &lt;CODE&gt;my_original.csv&lt;/CODE&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| inputlookup my_temp.csv
| eval temp="true"
| append [|inputlookup my_original.csv |  eval original="true"]
| eventstats count(temp) as tempCount
| where (tempCount&amp;gt;5 and temp="true") OR ((isnull(tempCount) OR (tempCount&amp;lt;=5)) AND original="true")
| outputlookup my_original.csv
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 04 Sep 2018 13:31:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-do-daily-outputlookup-searches-have-zero-results-and-leave/m-p/44979#M10621</guid>
      <dc:creator>koshyk</dc:creator>
      <dc:date>2018-09-04T13:31:08Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Outputlookup - dont write when no results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-do-daily-outputlookup-searches-have-zero-results-and-leave/m-p/44980#M10622</link>
      <description>&lt;P&gt;I had a similar problem - I have some key lookup files that I never want to be empty, because when they become empty, they can wreak havoc on my dashboards!  Reasons why they might become empty: low disk space or application issues (i.e., not normal situations).  To protect against this, I modified my automated lookup searches as follows:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;search that builds my_lookup.csv&amp;gt; | eval new=1 | append [|inputlookup my_lookup.csv | eval new=0] | eventstats sum(new) as newCount | eval useNum=if(newCount&amp;gt;5,1,0) | where new=useNum | fields - new newCount useNum | outputlookup my_lookup.csv
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What I like about my solution is it will exclusively use the new data if it exists and fall back to the old data if the new data has less than 5 events (i.e., there is no "merging" of the new and old data, which can cause issues if data has been deleted.)&lt;/P&gt;</description>
      <pubDate>Thu, 15 Nov 2018 02:13:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-do-daily-outputlookup-searches-have-zero-results-and-leave/m-p/44980#M10622</guid>
      <dc:creator>brannonrad</dc:creator>
      <dc:date>2018-11-15T02:13:53Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Outputlookup - dont write when no results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-do-daily-outputlookup-searches-have-zero-results-and-leave/m-p/44981#M10623</link>
      <description>&lt;P&gt;Hey, @pj, come back and Pick an answer to &lt;CODE&gt;Accept&lt;/CODE&gt; to close your question.  There are many good answers here, so you might consider an &lt;CODE&gt;UpVote&lt;/CODE&gt; or 2, also.&lt;/P&gt;</description>
      <pubDate>Sat, 13 Apr 2019 16:47:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-do-daily-outputlookup-searches-have-zero-results-and-leave/m-p/44981#M10623</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-04-13T16:47:19Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Outputlookup - dont write when no results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-do-daily-outputlookup-searches-have-zero-results-and-leave/m-p/44982#M10624</link>
      <description>&lt;P&gt;Clever solution, took a minute before I got it &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jul 2019 07:43:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-do-daily-outputlookup-searches-have-zero-results-and-leave/m-p/44982#M10624</guid>
      <dc:creator>simonverzijl</dc:creator>
      <dc:date>2019-07-15T07:43:12Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Outputlookup - dont write when no results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-do-daily-outputlookup-searches-have-zero-results-and-leave/m-p/541587#M153341</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/1406"&gt;@woodcock&lt;/a&gt;&amp;nbsp;that's a creative solution ! Nice&lt;/P&gt;</description>
      <pubDate>Fri, 26 Feb 2021 21:17:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-do-daily-outputlookup-searches-have-zero-results-and-leave/m-p/541587#M153341</guid>
      <dc:creator>aa70627</dc:creator>
      <dc:date>2021-02-26T21:17:22Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Outputlookup - dont write when no results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-do-daily-outputlookup-searches-have-zero-results-and-leave/m-p/599147#M208588</link>
      <description>&lt;P&gt;Always consider creating an ideas post if you see something you want.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://ideas.splunk.com/ideas/EID-I-1474" target="_blank"&gt;https://ideas.splunk.com/ideas/EID-I-1474&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 May 2022 17:54:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-do-daily-outputlookup-searches-have-zero-results-and-leave/m-p/599147#M208588</guid>
      <dc:creator>twollenslegel_s</dc:creator>
      <dc:date>2022-05-24T17:54:25Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Outputlookup - dont write when no results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-do-daily-outputlookup-searches-have-zero-results-and-leave/m-p/599148#M208589</link>
      <description>&lt;P class="lia-align-left"&gt;Another option i was just made aware of that will work today:&lt;/P&gt;&lt;P class="lia-align-left"&gt;This will just create the file if you have &amp;gt; 5000 but less than &amp;lt;10000 events, but can be adjusted to whatever values make sense.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&amp;lt;populating search&amp;gt;  | eventstats count as table_length
| where table_length &amp;gt; 5000 and table_length &amp;lt; 10000 | fields - table_length | outputlookup create_empty=false lookup.csv&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 May 2022 18:10:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-do-daily-outputlookup-searches-have-zero-results-and-leave/m-p/599148#M208589</guid>
      <dc:creator>twollenslegel_s</dc:creator>
      <dc:date>2022-05-24T18:10:07Z</dc:date>
    </item>
  </channel>
</rss>

