<?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 do I use a default value if latest(_time) cannot be found? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-use-a-default-value-if-latest-time-cannot-be-found/m-p/291532#M88062</link>
    <description>&lt;P&gt;For example, there is a way to use LOOKUP.&lt;BR /&gt;
※Please set all device ID in the LOOKUP file.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=&amp;lt;my_index&amp;gt; earliest=-2d primaryStatus=Active OR secondaryStatus=Active
 [ search index=&amp;lt;my_index&amp;gt; earliest=-15m primaryStatus=Failed secondaryStatus=Failed
 | fields deviceID
 | format ]
 | append [search inputlookup deviceID_list.csv|table deviceID]
 | stats latest(_time) as lastContact by deviceID
 | fillnull value="2+days" Average
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 20 Feb 2018 04:43:21 GMT</pubDate>
    <dc:creator>HiroshiSatoh</dc:creator>
    <dc:date>2018-02-20T04:43:21Z</dc:date>
    <item>
      <title>How do I use a default value if latest(_time) cannot be found?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-use-a-default-value-if-latest-time-cannot-be-found/m-p/291531#M88061</link>
      <description>&lt;P&gt;Hi, &lt;/P&gt;

&lt;P&gt;I'm trying to create a search that calculates how long a device has been offline, with a maximum of two days. However in its current form the search will only show sites if they have been online at some point in the last 2 days.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=&amp;lt;my_index&amp;gt; earliest=-2d primaryStatus=Active OR secondaryStatus=Active
[ search index=&amp;lt;my_index&amp;gt; earliest=-15m primaryStatus=Failed secondaryStatus=Failed
| fields deviceID
| format ]
| stats latest(_time) as lastContact by deviceID
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I have 3 devices that have never been online and I would like them to show up in the results with a default value for how long they've been offline. i.e. if any device has been offline for more than 2 days the downtime column will display "2+ Days" or if it's been offline for less than 2 days it should display that in 24 hour format: "1+12:30:00" (this part I already have working, it's just the first part that I can't figure out).&lt;/P&gt;

&lt;P&gt;I understand the first line will completely exclude these devices from the results because there will be no events where either of the conditions ( &lt;CODE&gt;primaryStatus=Active OR secondaryStatus=Active&lt;/CODE&gt; ) are true. But this is how I got it working for sites that have been online at some point during the selected time period.&lt;/P&gt;

&lt;P&gt;in the simplest terms I can come up with this is what I need to do:&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;find the latest(_time) as lastContact&lt;BR /&gt;
by deviceID where either of its&lt;BR /&gt;
interfaces are "Active" and if there&lt;BR /&gt;
are no such events set the lastContact&lt;BR /&gt;
to a default value.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Tue, 20 Feb 2018 01:31:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-use-a-default-value-if-latest-time-cannot-be-found/m-p/291531#M88061</guid>
      <dc:creator>packland</dc:creator>
      <dc:date>2018-02-20T01:31:59Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use a default value if latest(_time) cannot be found?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-use-a-default-value-if-latest-time-cannot-be-found/m-p/291532#M88062</link>
      <description>&lt;P&gt;For example, there is a way to use LOOKUP.&lt;BR /&gt;
※Please set all device ID in the LOOKUP file.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=&amp;lt;my_index&amp;gt; earliest=-2d primaryStatus=Active OR secondaryStatus=Active
 [ search index=&amp;lt;my_index&amp;gt; earliest=-15m primaryStatus=Failed secondaryStatus=Failed
 | fields deviceID
 | format ]
 | append [search inputlookup deviceID_list.csv|table deviceID]
 | stats latest(_time) as lastContact by deviceID
 | fillnull value="2+days" Average
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 20 Feb 2018 04:43:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-use-a-default-value-if-latest-time-cannot-be-found/m-p/291532#M88062</guid>
      <dc:creator>HiroshiSatoh</dc:creator>
      <dc:date>2018-02-20T04:43:21Z</dc:date>
    </item>
  </channel>
</rss>

