<?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 remove values of 0 from my search results? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-remove-values-of-0-from-my-search-results/m-p/349972#M103608</link>
    <description>&lt;P&gt;Yep, see the rest of my comment on how to clean it up.  I tend to edit heavily until my spelling and thinking is all straight.  &lt;/P&gt;</description>
    <pubDate>Thu, 09 Mar 2017 20:45:41 GMT</pubDate>
    <dc:creator>DalJeanis</dc:creator>
    <dc:date>2017-03-09T20:45:41Z</dc:date>
    <item>
      <title>How to remove values of 0 from my search results?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-remove-values-of-0-from-my-search-results/m-p/349965#M103601</link>
      <description>&lt;P&gt;I have a search that calculates a time duration for windows events logon and logout.   &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;....| eval  duration=tostring(logoff_time-logon_time,"duration")   
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I get a lot of time values for duration which is 00:00:00 and I would like to drop / remove from the results.&lt;/P&gt;

&lt;P&gt;What is the best way to remove those values?&lt;/P&gt;</description>
      <pubDate>Thu, 09 Mar 2017 19:02:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-remove-values-of-0-from-my-search-results/m-p/349965#M103601</guid>
      <dc:creator>packet_hunter</dc:creator>
      <dc:date>2017-03-09T19:02:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove values of 0 from my search results?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-remove-values-of-0-from-my-search-results/m-p/349966#M103602</link>
      <description>&lt;P&gt;Take your pick...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| where duration!=0
| where duration&amp;gt;0
| search duration!=0
| search duration&amp;gt;0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;...but do it before reformatting/calculating, to save the mips.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Mar 2017 19:26:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-remove-values-of-0-from-my-search-results/m-p/349966#M103602</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-03-09T19:26:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove values of 0 from my search results?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-remove-values-of-0-from-my-search-results/m-p/349967#M103603</link>
      <description>&lt;P&gt;actually in this case the "where" syntax did not work... but search did, just fyi&lt;/P&gt;</description>
      <pubDate>Thu, 09 Mar 2017 19:37:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-remove-values-of-0-from-my-search-results/m-p/349967#M103603</guid>
      <dc:creator>packet_hunter</dc:creator>
      <dc:date>2017-03-09T19:37:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove values of 0 from my search results?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-remove-values-of-0-from-my-search-results/m-p/349968#M103604</link>
      <description>&lt;P&gt;what is the query/transforming command to calculate duration?&lt;/P&gt;</description>
      <pubDate>Thu, 09 Mar 2017 19:37:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-remove-values-of-0-from-my-search-results/m-p/349968#M103604</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-03-09T19:37:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove values of 0 from my search results?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-remove-values-of-0-from-my-search-results/m-p/349969#M103605</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;index=wineventlog sourcetype=WinEventLog
Security_ID="some_Name_ID" (EventCode=4624 OR EventCode=4634) 
|sort Logon_ID 
| stats  
latest(eval(if(EventCode=4624,_time, null()))) as logon_time,     
latest(eval(if(EventCode=4634,_time,null()))) as logoff_time, 
latest(eval(if(EventCode=4624,Source_Network_Address, null()))) as Src_Network_Address,
latest(eval(if(EventCode=4624,Logon_GUID, null()))) as LgnGUID, 
by Logon_ID 
| eval  logoff_time = if(logoff_time&amp;lt;logon_time OR isnull(logoff_time), "Session in Progress",logoff_time)     
| eval  logon_time = if(isnull(logon_time),"Logon time out of range", logon_time)     
| eval  duration=tostring(logoff_time-logon_time,"duration") 
| eval  logon_time=if(isint(logon_time),strftime(logon_time, "%b %d, %I:%M %p"), logon_time) 
| eval  logoff_time=if(isint(logoff_time),strftime(logoff_time, "%b %d, %I:%M %p"),logoff_time) 

| where duration&amp;gt;"00:01:00" OR isnull(duration)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 09 Mar 2017 19:57:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-remove-values-of-0-from-my-search-results/m-p/349969#M103605</guid>
      <dc:creator>packet_hunter</dc:creator>
      <dc:date>2017-03-09T19:57:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove values of 0 from my search results?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-remove-values-of-0-from-my-search-results/m-p/349970#M103606</link>
      <description>&lt;P&gt;Heh...which is exactly why I put all four there.  Sometimes &lt;CODE&gt;where&lt;/CODE&gt; and &lt;CODE&gt;search&lt;/CODE&gt; are a bit finnicky.  &lt;/P&gt;

&lt;P&gt;You can use coalesce to get rid of the nulls, which simplifies the code slightly -&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;&lt;P&gt;&lt;CODE&gt;coalesce(a,b)&lt;/CODE&gt; is the equivalent of &lt;CODE&gt;if(isnull(a),b,a)&lt;/CODE&gt; or &lt;CODE&gt;if(isnotnull(a),a,b)&lt;/CODE&gt;. &lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;P&gt;&lt;CODE&gt;coalesce(a,b,c)&lt;/CODE&gt; is the equivalent of &lt;CODE&gt;if(isnull(a),if(isnull(b),c,b),a)&lt;/CODE&gt; or &lt;CODE&gt;if(isnotnull(a),a,if(isnotnull(b),b,c))&lt;/CODE&gt;&lt;/P&gt;&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;...so the coalesce  version looks like this...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | eval  logon_time = coalesce(logon_time,"Logon time out of range")     
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;...or, with simple null fields like that, you could also use the &lt;CODE&gt;fillnull&lt;/CODE&gt; verb.  In this case it doesn't save anything, but if you had a list of fields to all default to the same thing,  then &lt;CODE&gt;fillnull&lt;/CODE&gt; can be much more efficient to code.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | fillnull value="Logon time out of range" logon_time 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Also, minor note, &lt;CODE&gt;sort&lt;/CODE&gt; has a default number of records that it will return if you don't tell it to return all of them, so get in the habit of putting the number 0 after every sort verb...  &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; |sort 0 Logon_ID _time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;However, you don't need to &lt;CODE&gt;sort&lt;/CODE&gt; anything before that &lt;CODE&gt;stats&lt;/CODE&gt; command anyway.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Mar 2017 20:18:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-remove-values-of-0-from-my-search-results/m-p/349970#M103606</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-03-09T20:18:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove values of 0 from my search results?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-remove-values-of-0-from-my-search-results/m-p/349971#M103607</link>
      <description>&lt;P&gt;yes thank you for "search", I was using "where" and got stuck.&lt;BR /&gt;
I got it to work with ... | where duration &amp;gt; "00:00:00",    quotes were needed as it was a string... I believe&lt;BR /&gt;
I posted the entire search above... probably could be cleaned up&lt;BR /&gt;
thanks again&lt;/P&gt;</description>
      <pubDate>Thu, 09 Mar 2017 20:23:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-remove-values-of-0-from-my-search-results/m-p/349971#M103607</guid>
      <dc:creator>packet_hunter</dc:creator>
      <dc:date>2017-03-09T20:23:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove values of 0 from my search results?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-remove-values-of-0-from-my-search-results/m-p/349972#M103608</link>
      <description>&lt;P&gt;Yep, see the rest of my comment on how to clean it up.  I tend to edit heavily until my spelling and thinking is all straight.  &lt;/P&gt;</description>
      <pubDate>Thu, 09 Mar 2017 20:45:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-remove-values-of-0-from-my-search-results/m-p/349972#M103608</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-03-09T20:45:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove values of 0 from my search results?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-remove-values-of-0-from-my-search-results/m-p/349973#M103609</link>
      <description>&lt;P&gt;thanks  very helpful&lt;/P&gt;</description>
      <pubDate>Thu, 09 Mar 2017 20:49:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-remove-values-of-0-from-my-search-results/m-p/349973#M103609</guid>
      <dc:creator>packet_hunter</dc:creator>
      <dc:date>2017-03-09T20:49:13Z</dc:date>
    </item>
  </channel>
</rss>

