<?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 Unable to do simple calculation of aggregate durations between 2 states by host in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Unable-to-do-simple-calculation-of-aggregate-durations-between-2/m-p/676299#M231320</link>
    <description>&lt;P&gt;Given that per host there are 2 events logged, one indicating transition to active and one indicating transition to inactive.&amp;nbsp; I cant figure out a query that can accurately do this per host given the following stipulations.&lt;BR /&gt;&lt;BR /&gt;Given the first event within the query time range, it can be assumed the host was in the opposite state prior.&lt;BR /&gt;&lt;BR /&gt;Only calculate transitions between the 2 states, if there are multiple same events within transitions, calculate of the time of the first occuring.&lt;BR /&gt;&lt;BR /&gt;Include the latest condition up until the time the search is run.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 01 Feb 2024 17:11:13 GMT</pubDate>
    <dc:creator>smahoney</dc:creator>
    <dc:date>2024-02-01T17:11:13Z</dc:date>
    <item>
      <title>Unable to do simple calculation of aggregate durations between 2 states by host</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Unable-to-do-simple-calculation-of-aggregate-durations-between-2/m-p/676299#M231320</link>
      <description>&lt;P&gt;Given that per host there are 2 events logged, one indicating transition to active and one indicating transition to inactive.&amp;nbsp; I cant figure out a query that can accurately do this per host given the following stipulations.&lt;BR /&gt;&lt;BR /&gt;Given the first event within the query time range, it can be assumed the host was in the opposite state prior.&lt;BR /&gt;&lt;BR /&gt;Only calculate transitions between the 2 states, if there are multiple same events within transitions, calculate of the time of the first occuring.&lt;BR /&gt;&lt;BR /&gt;Include the latest condition up until the time the search is run.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Feb 2024 17:11:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Unable-to-do-simple-calculation-of-aggregate-durations-between-2/m-p/676299#M231320</guid>
      <dc:creator>smahoney</dc:creator>
      <dc:date>2024-02-01T17:11:13Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to do simple calculation of aggregate durations between 2 states by host</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Unable-to-do-simple-calculation-of-aggregate-durations-between-2/m-p/676378#M231337</link>
      <description>&lt;P&gt;"simple" is a subjective term!&lt;/P&gt;&lt;P&gt;Assuming you can evaluate state based on the events as being either 0 or 1 (I have used a random number to simulate different events), then you could try something like this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval state=if(random()%5 == 0, 0, 1)
| streamstats range(state) as changed count as host_event by host global=f window=2
| eval changed = if(host_event == 1, 1, changed)
| where changed == 1
| streamstats range(_time) as interval last(state) as state by host global=f window=2
| appendpipe
    [| stats last(state) as state last(_time) as last_event by host
    | addinfo
    | eval _time=info_max_time
    | eval interval=_time-last_event
    | fields - info_* last_event]&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 02 Feb 2024 10:59:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Unable-to-do-simple-calculation-of-aggregate-durations-between-2/m-p/676378#M231337</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2024-02-02T10:59:01Z</dc:date>
    </item>
  </channel>
</rss>

