<?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: Show the current duration of equipment where the Status is not &amp;quot;null&amp;quot; in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Show-the-current-duration-of-equipment-where-the-Status-is-not/m-p/677260#M231581</link>
    <description>&lt;P&gt;If I understand your requirements correctly, the easiest approach would be to use the transaction command with relatively low thresholds for transaction continuity. But the transaction command is relatively resource-intensive so you might want to try streamstats-based approach instead.&lt;/P&gt;</description>
    <pubDate>Mon, 12 Feb 2024 11:52:21 GMT</pubDate>
    <dc:creator>PickleRick</dc:creator>
    <dc:date>2024-02-12T11:52:21Z</dc:date>
    <item>
      <title>Show the current duration of equipment where the Status is not "null"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Show-the-current-duration-of-equipment-where-the-Status-is-not/m-p/677258#M231579</link>
      <description>&lt;P&gt;Hello, I have the following data:&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I want to use this data to setup a dashboard. In this dashboard I want to show the current duration of equipment where the Status is not "null" (null is a string in this case and not a null value)&lt;BR /&gt;&lt;BR /&gt;Each JobID only has one EquipmentID&lt;BR /&gt;The same status can occur and disappear multiple times per JobID&lt;BR /&gt;There are around 10 different status&lt;BR /&gt;I want to the results to show only durations above 60 seconds&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;If the current time is 12:21 I would like the to look like this.&lt;/P&gt;
&lt;TABLE width="219"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="91"&gt;EquipmentID&amp;nbsp;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="64"&gt;Duration&lt;/TD&gt;
&lt;TD width="64"&gt;Most_recent_status&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;120&lt;/TD&gt;
&lt;TD&gt;Z&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE width="312px"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="84.0375px"&gt;Time&lt;/TD&gt;
&lt;TD width="104.488px"&gt;EquipmentID&lt;/TD&gt;
&lt;TD width="61.875px"&gt;Status&lt;/TD&gt;
&lt;TD width="60.8px"&gt;JobID&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="84.0375px"&gt;12:00&lt;/TD&gt;
&lt;TD width="104.488px"&gt;1&lt;/TD&gt;
&lt;TD width="61.875px"&gt;"null"&lt;/TD&gt;
&lt;TD width="60.8px"&gt;10&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="84.0375px"&gt;12:01&lt;/TD&gt;
&lt;TD width="104.488px"&gt;2&lt;/TD&gt;
&lt;TD width="61.875px"&gt;"null"&lt;/TD&gt;
&lt;TD width="60.8px"&gt;20&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="84.0375px"&gt;12:02&lt;/TD&gt;
&lt;TD width="104.488px"&gt;2&lt;/TD&gt;
&lt;TD width="61.875px"&gt;X&lt;/TD&gt;
&lt;TD width="60.8px"&gt;20&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="84.0375px"&gt;12:03&lt;/TD&gt;
&lt;TD width="104.488px"&gt;2&lt;/TD&gt;
&lt;TD width="61.875px"&gt;X&lt;/TD&gt;
&lt;TD width="60.8px"&gt;20&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="84.0375px"&gt;12:04&lt;/TD&gt;
&lt;TD width="104.488px"&gt;1&lt;/TD&gt;
&lt;TD width="61.875px"&gt;X&lt;/TD&gt;
&lt;TD width="60.8px"&gt;10&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="84.0375px"&gt;12:05&lt;/TD&gt;
&lt;TD width="104.488px"&gt;1&lt;/TD&gt;
&lt;TD width="61.875px"&gt;Y&lt;/TD&gt;
&lt;TD width="60.8px"&gt;10&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="84.0375px"&gt;12:06&lt;/TD&gt;
&lt;TD width="104.488px"&gt;1&lt;/TD&gt;
&lt;TD width="61.875px"&gt;Y&lt;/TD&gt;
&lt;TD width="60.8px"&gt;20&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="84.0375px"&gt;12:07&lt;/TD&gt;
&lt;TD width="104.488px"&gt;2&lt;/TD&gt;
&lt;TD width="61.875px"&gt;Y&lt;/TD&gt;
&lt;TD width="60.8px"&gt;20&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="84.0375px"&gt;12:08&lt;/TD&gt;
&lt;TD width="104.488px"&gt;1&lt;/TD&gt;
&lt;TD width="61.875px"&gt;X&lt;/TD&gt;
&lt;TD width="60.8px"&gt;10&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="84.0375px"&gt;12:09&lt;/TD&gt;
&lt;TD width="104.488px"&gt;2&lt;/TD&gt;
&lt;TD width="61.875px"&gt;Y&lt;/TD&gt;
&lt;TD width="60.8px"&gt;20&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="84.0375px"&gt;12:10&lt;/TD&gt;
&lt;TD width="104.488px"&gt;1&lt;/TD&gt;
&lt;TD width="61.875px"&gt;"null"&lt;/TD&gt;
&lt;TD width="60.8px"&gt;11&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="84.0375px"&gt;12:11&lt;/TD&gt;
&lt;TD width="104.488px"&gt;2&lt;/TD&gt;
&lt;TD width="61.875px"&gt;"null"&lt;/TD&gt;
&lt;TD width="60.8px"&gt;21&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="84.0375px"&gt;12:12&lt;/TD&gt;
&lt;TD width="104.488px"&gt;2&lt;/TD&gt;
&lt;TD width="61.875px"&gt;"null"&lt;/TD&gt;
&lt;TD width="60.8px"&gt;21&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="84.0375px"&gt;12:13&lt;/TD&gt;
&lt;TD width="104.488px"&gt;1&lt;/TD&gt;
&lt;TD width="61.875px"&gt;"null"&lt;/TD&gt;
&lt;TD width="60.8px"&gt;11&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="84.0375px"&gt;12:14&lt;/TD&gt;
&lt;TD width="104.488px"&gt;1&lt;/TD&gt;
&lt;TD width="61.875px"&gt;"null"&lt;/TD&gt;
&lt;TD width="60.8px"&gt;11&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="84.0375px"&gt;12:15&lt;/TD&gt;
&lt;TD width="104.488px"&gt;2&lt;/TD&gt;
&lt;TD width="61.875px"&gt;X&lt;/TD&gt;
&lt;TD width="60.8px"&gt;21&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="84.0375px"&gt;12:16&lt;/TD&gt;
&lt;TD width="104.488px"&gt;1&lt;/TD&gt;
&lt;TD width="61.875px"&gt;X&lt;/TD&gt;
&lt;TD width="60.8px"&gt;11&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="84.0375px"&gt;12:17&lt;/TD&gt;
&lt;TD width="104.488px"&gt;2&lt;/TD&gt;
&lt;TD width="61.875px"&gt;X&lt;/TD&gt;
&lt;TD width="60.8px"&gt;21&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="84.0375px"&gt;12:18&lt;/TD&gt;
&lt;TD width="104.488px"&gt;1&lt;/TD&gt;
&lt;TD width="61.875px"&gt;"null"&lt;/TD&gt;
&lt;TD width="60.8px"&gt;11&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="84.0375px"&gt;12:19&lt;/TD&gt;
&lt;TD width="104.488px"&gt;2&lt;/TD&gt;
&lt;TD width="61.875px"&gt;Z&lt;/TD&gt;
&lt;TD width="60.8px"&gt;21&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="84.0375px"&gt;12:20&lt;/TD&gt;
&lt;TD width="104.488px"&gt;2&lt;/TD&gt;
&lt;TD width="61.875px"&gt;Z&lt;/TD&gt;
&lt;TD width="60.8px"&gt;21&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;This is the query I use now only the duration_now resets every time a new event occurs&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;index=X sourcetype=Y  JobID!=”null”

|sort _time 0

| stats last(_time) as first_time last(Status) as "First_Status" latest(status) as Last_status latest(_time) as latest_times  values(EquipmentID) as Equipment   by JobID

| eval final_duration = case(Last_status ="null", round(latest_times - first_time,2))

| eval duration_now = case(isnull(final_duration), round(now() - first_time,2))

| eval first_time=strftime(first_time, "%Y-%m-%d %H:%M:%S")

| eval latest_times=strftime(latest_times, "%Y-%m-%d %H:%M:%S")

| sort - first_time&lt;/LI-CODE&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;Any help would be greatly appreciated&lt;/P&gt;</description>
      <pubDate>Mon, 12 Feb 2024 13:09:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Show-the-current-duration-of-equipment-where-the-Status-is-not/m-p/677258#M231579</guid>
      <dc:creator>Roy1</dc:creator>
      <dc:date>2024-02-12T13:09:32Z</dc:date>
    </item>
    <item>
      <title>Re: Show the current duration of equipment where the Status is not "null"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Show-the-current-duration-of-equipment-where-the-Status-is-not/m-p/677259#M231580</link>
      <description>&lt;P&gt;If I understand correctly, you want to know when the equipment changed to its current status so long as the current status is not "null"?&lt;/P&gt;&lt;P&gt;Try something like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eventstats last(Status) as lastStatus by EquipmentID
| where lastStatus!="null"
| streamstats last(Status) as previous current=f global=f by EquipmentID
| where Status=lastStatus and Status != previous
| stats last(_time) as lastTime last(Status) as lastStatus by EquipmentID
| eval duration=now()-lastTime&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 12 Feb 2024 11:48:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Show-the-current-duration-of-equipment-where-the-Status-is-not/m-p/677259#M231580</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2024-02-12T11:48:33Z</dc:date>
    </item>
    <item>
      <title>Re: Show the current duration of equipment where the Status is not "null"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Show-the-current-duration-of-equipment-where-the-Status-is-not/m-p/677260#M231581</link>
      <description>&lt;P&gt;If I understand your requirements correctly, the easiest approach would be to use the transaction command with relatively low thresholds for transaction continuity. But the transaction command is relatively resource-intensive so you might want to try streamstats-based approach instead.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Feb 2024 11:52:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Show-the-current-duration-of-equipment-where-the-Status-is-not/m-p/677260#M231581</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2024-02-12T11:52:21Z</dc:date>
    </item>
    <item>
      <title>Re: Show the current duration of equipment where the Status is not "null"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Show-the-current-duration-of-equipment-where-the-Status-is-not/m-p/677267#M231583</link>
      <description>&lt;P&gt;Thanks for the reply unfortunately it doesn’t seem to work completely.&lt;BR /&gt;I have the timerange set to the previous 15 minutes&lt;BR /&gt;&lt;BR /&gt;what I think happens is that the query takes the first !=null and starts the duration from there. I fixed this by adding |sort _time 0 to the top of the query but then it only tracks the time of the last status. I would like for it to track the total time all statuses are&amp;nbsp; !=null&lt;BR /&gt;&lt;BR /&gt;When I use your query I get durations of ~900 seconds while they are between 1-100&lt;BR /&gt;&lt;BR /&gt;When I add the time sort I only get the duration of X and not X+Y (from the following events)&lt;BR /&gt;&lt;BR /&gt;Do you happen to know how I get the duration of X+Y?&lt;/P&gt;&lt;TABLE width="316"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="94"&gt;Time&lt;/TD&gt;&lt;TD width="94"&gt;EquipmentID&lt;/TD&gt;&lt;TD width="64"&gt;Status&lt;/TD&gt;&lt;TD width="64"&gt;JobID&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;12:00&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;X&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;12:01&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;"null"&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;12:02&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;"null"&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;12:03&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;Y&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;12:04&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;Y&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;12:05&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;Y&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;12:06&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;Y&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;12:07&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;X&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;12:08&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;X&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Mon, 12 Feb 2024 12:15:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Show-the-current-duration-of-equipment-where-the-Status-is-not/m-p/677267#M231583</guid>
      <dc:creator>Roy1</dc:creator>
      <dc:date>2024-02-12T12:15:22Z</dc:date>
    </item>
    <item>
      <title>Re: Show the current duration of equipment where the Status is not "null"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Show-the-current-duration-of-equipment-where-the-Status-is-not/m-p/677268#M231584</link>
      <description>&lt;P&gt;This is different to your original question - using this criteria, with your first set of events, the duration would have been 360 not 120, correct?&lt;/P&gt;</description>
      <pubDate>Mon, 12 Feb 2024 12:34:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Show-the-current-duration-of-equipment-where-the-Status-is-not/m-p/677268#M231584</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2024-02-12T12:34:44Z</dc:date>
    </item>
    <item>
      <title>Re: Show the current duration of equipment where the Status is not "null"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Show-the-current-duration-of-equipment-where-the-Status-is-not/m-p/677269#M231585</link>
      <description>&lt;P&gt;I see, you are correct I made a mistake in my example events the 120 should indeed be 360. Thanks for catching my mistake&lt;/P&gt;</description>
      <pubDate>Mon, 12 Feb 2024 12:37:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Show-the-current-duration-of-equipment-where-the-Status-is-not/m-p/677269#M231585</guid>
      <dc:creator>Roy1</dc:creator>
      <dc:date>2024-02-12T12:37:35Z</dc:date>
    </item>
    <item>
      <title>Re: Show the current duration of equipment where the Status is not "null"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Show-the-current-duration-of-equipment-where-the-Status-is-not/m-p/677271#M231586</link>
      <description>&lt;LI-CODE lang="markup"&gt;| sort 0 _time
| eventstats last(Status) as lastStatus by EquipmentID
| where lastStatus!="null"
| streamstats last(Status) as previous current=f global=f by EquipmentID
| where Status!="null" and previous=="null"
| stats last(_time) as lastTime last(lastStatus) as lastStatus by EquipmentID
| eval duration=now()-lastTime&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 12 Feb 2024 12:42:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Show-the-current-duration-of-equipment-where-the-Status-is-not/m-p/677271#M231586</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2024-02-12T12:42:29Z</dc:date>
    </item>
    <item>
      <title>Re: Show the current duration of equipment where the Status is not "null"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Show-the-current-duration-of-equipment-where-the-Status-is-not/m-p/677278#M231589</link>
      <description>&lt;P&gt;This works perfectly thank you very much.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Feb 2024 13:02:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Show-the-current-duration-of-equipment-where-the-Status-is-not/m-p/677278#M231589</guid>
      <dc:creator>Roy1</dc:creator>
      <dc:date>2024-02-12T13:02:45Z</dc:date>
    </item>
  </channel>
</rss>

