<?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 check and count the status before a certain event? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-check-and-count-the-status-before-a-certain-event/m-p/442963#M172435</link>
    <description>&lt;P&gt;Hi again @adonio,&lt;/P&gt;

&lt;P&gt;Now I need to calculate total count of Function after Status 1, how to do that?&lt;BR /&gt;
The result should be as follow:&lt;/P&gt;

&lt;P&gt;Status...........................count of Function&lt;BR /&gt;
 Status1 ........................3&lt;/P&gt;</description>
    <pubDate>Tue, 26 Mar 2019 16:00:02 GMT</pubDate>
    <dc:creator>jyab6z</dc:creator>
    <dc:date>2019-03-26T16:00:02Z</dc:date>
    <item>
      <title>How to check and count the status before a certain event?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-check-and-count-the-status-before-a-certain-event/m-p/442958#M172430</link>
      <description>&lt;P&gt;Our log looks like as following after basic search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Date..............Time...........................UserID..................Function/Status
20190227 03:56:22:788 [njdh00t2ldqwuocvtdzdywcr] - Function
20190227 03:55:09:933 [njdh00t2ldqwuocvtdzdywcr] - Status 1.
20190227 03:46:35:503 [njdh00t2ldqwuocvtdzdywcr] - Function
20190227 03:46:32:587 [njdh00t2ldqwuocvtdzdywcr] - Function
20190227 03:45:14:681 [njdh00t2ldqwuocvtdzdywcr] - Function
20190227 03:44:56:292 [njdh00t2ldqwuocvtdzdywcr] - Status 2.
20190227 03:33:15:450 [njdh00t2ldqwuocvtdzdywcr] - Status 1.
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I want to count percentage of Status 1 and Status 2 right before Function event for same Date and same UserID.&lt;BR /&gt;
In this case, the result should be as follow:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Status...........................count
Status1 ........................1
Status2 ........................1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Due to first Status 1 event was not counted. The search need to check the Status before Function event, only the Status followed by a Function event should be counted. &lt;/P&gt;

&lt;P&gt;Any idea? Thanks in advance! &lt;/P&gt;</description>
      <pubDate>Mon, 18 Mar 2019 07:31:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-check-and-count-the-status-before-a-certain-event/m-p/442958#M172430</guid>
      <dc:creator>jyab6z</dc:creator>
      <dc:date>2019-03-18T07:31:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to check and count the status before a certain event?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-check-and-count-the-status-before-a-certain-event/m-p/442959#M172431</link>
      <description>&lt;P&gt;hello there,&lt;/P&gt;

&lt;P&gt;hope i understood your question.&lt;BR /&gt;
try and run the below search anywhere, i added extra lines with another Status, &lt;CODE&gt;Status 3&lt;/CODE&gt;:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults count=1 
| eval data = "20190227 03:56:22:788 [njdh00t2ldqwuocvtdzdywcr] - Function;;;20190227 03:55:09:933 [njdh00t2ldqwuocvtdzdywcr] - Status 1;;;20190227 03:46:35:503 [njdh00t2ldqwuocvtdzdywcr] - Function;;;20190227 03:46:32:587 [njdh00t2ldqwuocvtdzdywcr] - Function;;;20190227 03:45:14:681 [njdh00t2ldqwuocvtdzdywcr] - Function;;;20190227 03:44:56:292 [njdh00t2ldqwuocvtdzdywcr] - Status 2;;;20190227 03:33:15:450 [njdh00t2ldqwuocvtdzdywcr] - Status 1;;;20190227 03:56:22:788 [njdh00t2ldqwuocvtdzdywcr] - Function;;;20190227 04:55:09:933 [njdh00t2ldqwuocvtdzdywcr] - Status 2;;;20190227 04:46:35:503 [njdh00t2ldqwuocvtdzdywcr] - Function;;;20190227 04:46:32:587 [njdh00t2ldqwuocvtdzdywcr] - Function;;;20190227 04:45:14:681 [njdh00t2ldqwuocvtdzdywcr] - Function;;;20190227 04:44:56:292 [njdh00t2ldqwuocvtdzdywcr] - Status 3;;;20190227 04:33:15:450 [njdh00t2ldqwuocvtdzdywcr] - Status 1"
| makemv delim=";;;" data
| mvexpand data
| rex field=data "(?&amp;lt;YMD&amp;gt;[^\s]+)\s+(?&amp;lt;HMS&amp;gt;[^\s]+)\s+(?&amp;lt;u_id&amp;gt;[^\s]+)\s+\-\s+(?&amp;lt;function&amp;gt;[^\|]+)"
| table YMD HMS u_id function
| rename COMMENT as "the above generates data below is the solution" 
| reverse
| streamstats window=1 current=f last(function) as previous_function
| stats values(function) as original_function values(previous_function) as origial_previous_function by YMD u_id
| mvexpand original_function
| mvexpand origial_previous_function
| eval should_count = if(origial_previous_function LIKE "Status%" AND original_function=="Function",1,0)
| stats sum(should_count) by YMD origial_previous_function
| where like(origial_previous_function,"Status%")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hope it helps&lt;/P&gt;</description>
      <pubDate>Mon, 18 Mar 2019 12:07:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-check-and-count-the-status-before-a-certain-event/m-p/442959#M172431</guid>
      <dc:creator>adonio</dc:creator>
      <dc:date>2019-03-18T12:07:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to check and count the status before a certain event?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-check-and-count-the-status-before-a-certain-event/m-p/442960#M172432</link>
      <description>&lt;P&gt;Hi @adonio,&lt;/P&gt;

&lt;P&gt;It helps alot! Thank you! One more question, what if the log continue with other user's info,? For instance:&lt;/P&gt;

&lt;P&gt;Date..............Time...........................UserID..................Function/Status&lt;BR /&gt;
20190227 03:56:22:788 [njdh00t2ldqwuocvtdzdywcr] - Function&lt;BR /&gt;
20190227 03:55:09:933 [njdh00t2ldqwuocvtdzdywcr] - Status 1.&lt;BR /&gt;
20190227 03:46:35:503 [njdh00t2ldqwuocvtdzdywcr] - Function&lt;BR /&gt;
20190227 03:46:32:587 [njdh00t2ldqwuocvtdzdywcr] - Function&lt;BR /&gt;
20190227 03:45:14:681 [njdh00t2ldqwuocvtdzdywcr] - Function&lt;BR /&gt;
20190227 03:44:56:292 [njdh00t2ldqwuocvtdzdywcr] - Status 2.&lt;BR /&gt;
20190227 03:33:15:450 [njdh00t2ldqwuocvtdzdywcr] - Status 1.&lt;BR /&gt;
20190227 03:32:32:587 [new user here] - Function&lt;BR /&gt;
20190227 03:31:14:681 [new user here] - Function&lt;BR /&gt;
20190227 03:30:56:292 [new user here] - Status 2.&lt;BR /&gt;
20190227 03:29:15:450 [new user here] - Status 1.&lt;/P&gt;

&lt;P&gt;Can I add an empty line between different users somehow?&lt;BR /&gt;
Thank you alot!&lt;/P&gt;</description>
      <pubDate>Mon, 18 Mar 2019 14:28:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-check-and-count-the-status-before-a-certain-event/m-p/442960#M172432</guid>
      <dc:creator>jyab6z</dc:creator>
      <dc:date>2019-03-18T14:28:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to check and count the status before a certain event?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-check-and-count-the-status-before-a-certain-event/m-p/442961#M172433</link>
      <description>&lt;P&gt;not sure what do you mean by "add an empty line ..."&lt;BR /&gt;&lt;BR /&gt;
the search logic should cover also different users &lt;/P&gt;</description>
      <pubDate>Mon, 18 Mar 2019 17:03:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-check-and-count-the-status-before-a-certain-event/m-p/442961#M172433</guid>
      <dc:creator>adonio</dc:creator>
      <dc:date>2019-03-18T17:03:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to check and count the status before a certain event?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-check-and-count-the-status-before-a-certain-event/m-p/442962#M172434</link>
      <description>&lt;P&gt;Yea, never mind, my bad! Thank you! &lt;/P&gt;</description>
      <pubDate>Tue, 19 Mar 2019 08:24:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-check-and-count-the-status-before-a-certain-event/m-p/442962#M172434</guid>
      <dc:creator>jyab6z</dc:creator>
      <dc:date>2019-03-19T08:24:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to check and count the status before a certain event?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-check-and-count-the-status-before-a-certain-event/m-p/442963#M172435</link>
      <description>&lt;P&gt;Hi again @adonio,&lt;/P&gt;

&lt;P&gt;Now I need to calculate total count of Function after Status 1, how to do that?&lt;BR /&gt;
The result should be as follow:&lt;/P&gt;

&lt;P&gt;Status...........................count of Function&lt;BR /&gt;
 Status1 ........................3&lt;/P&gt;</description>
      <pubDate>Tue, 26 Mar 2019 16:00:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-check-and-count-the-status-before-a-certain-event/m-p/442963#M172435</guid>
      <dc:creator>jyab6z</dc:creator>
      <dc:date>2019-03-26T16:00:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to check and count the status before a certain event?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-check-and-count-the-status-before-a-certain-event/m-p/442964#M172436</link>
      <description>&lt;P&gt;can you open another question?&lt;BR /&gt;
this one is marked accepted to the world so less chances other community members will open it and help&lt;/P&gt;</description>
      <pubDate>Tue, 26 Mar 2019 16:27:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-check-and-count-the-status-before-a-certain-event/m-p/442964#M172436</guid>
      <dc:creator>adonio</dc:creator>
      <dc:date>2019-03-26T16:27:16Z</dc:date>
    </item>
  </channel>
</rss>

