<?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 get &amp;quot;duration&amp;quot; without use transaction in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-quot-duration-quot-without-use-transaction/m-p/193885#M55880</link>
    <description>&lt;P&gt;Hi pisc,&lt;/P&gt;

&lt;P&gt;you can use &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.1.1/SearchReference/Streamstats"&gt;&lt;CODE&gt;streamstats&lt;/CODE&gt;&lt;/A&gt; like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;yourBaseSearchHere 
| streamstats current=false last(STATUS) as last_status last(_time) as time_of_change by ID
| where STATUS!=last_status 
| eval duration=now()-time_of_change 
| eval duration=strftime(duration, "%H:%M") 
| table _time, HOSTNAME, ID, duration
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;this is un-tested since I'm missing the real events, so maybe you will need to adapt some things to match your needs.&lt;/P&gt;

&lt;P&gt;hope this helps ...&lt;/P&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
    <pubDate>Tue, 10 Jun 2014 11:06:47 GMT</pubDate>
    <dc:creator>MuS</dc:creator>
    <dc:date>2014-06-10T11:06:47Z</dc:date>
    <item>
      <title>How to get "duration" without use transaction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-quot-duration-quot-without-use-transaction/m-p/193884#M55879</link>
      <description>&lt;P&gt;transaction関数を使用すれば、グルーピングしたログの間隔（duration）を取得出来ますが、transactionを使用しない場合のduration取得方法をご教授頂けますでしょうか。&lt;/P&gt;

&lt;P&gt;下記のログを用いてPCの操作時間のユーザごとの総計を取得したいと思っています。&lt;/P&gt;

&lt;P&gt;user01の場合は23:00～23:30で使用時間が30minになりますが、user02の場合、Startの次はuser03によるPC02の使用ということで、23:10～23:35で25minになります。&lt;/P&gt;

&lt;P&gt;transactionを使用し、startswith=Start、endswith=Endとした場合は、上記のuser02のEndがない為、グルーピングがうまくいきません。&lt;/P&gt;

&lt;P&gt;この場合のdurationの取得方法、またはtransactionをうまく活用できないか、ご教授頂けますでしょうか。&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;DATE | ID | HOSTNAME | STATUS&lt;/P&gt;

&lt;P&gt;14/05/31 23:00 | user01 | PC01 | Start&lt;/P&gt;

&lt;P&gt;14/05/31 23:10 | user02 | PC02 | Start&lt;/P&gt;

&lt;P&gt;14/05/31 23:30 | user01 | PC01 | End&lt;/P&gt;

&lt;P&gt;14/05/31 23:35 | user03 | PC02 | Start&lt;/P&gt;

&lt;P&gt;14/05/31 23:50 | user03 | PC02 | End&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;HR /&gt;

&lt;P&gt;以下、情報が不足してましたので追記します。&lt;/P&gt;

&lt;P&gt;STATUSカラムには「Timeout」というログが存在します。&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;DATE | ID | HOSTNAME | STATUS&lt;/P&gt;

&lt;P&gt;14/05/31 23:35 | user03 | PC02 | Start&lt;/P&gt;

&lt;P&gt;14/05/31 23:50 | | PC02 | Timeout&lt;/P&gt;

&lt;P&gt;14/05/31 23:55 | user04 | PC02 | Start&lt;/P&gt;

&lt;P&gt;14/05/31 23:59 | user04 | PC02 | End&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;Timeoutログがある場合は、IDは空欄です。&lt;BR /&gt;
この場合、user03は23:35～23:50の使用時間になります。&lt;/P&gt;

&lt;P&gt;こういったログを1か月分集計し、HOSTNAMEごとの使用時間、IDごとの使用時間を集計したいと考えています。&lt;/P&gt;</description>
      <pubDate>Tue, 10 Jun 2014 07:40:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-quot-duration-quot-without-use-transaction/m-p/193884#M55879</guid>
      <dc:creator>pisc</dc:creator>
      <dc:date>2014-06-10T07:40:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to get "duration" without use transaction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-quot-duration-quot-without-use-transaction/m-p/193885#M55880</link>
      <description>&lt;P&gt;Hi pisc,&lt;/P&gt;

&lt;P&gt;you can use &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.1.1/SearchReference/Streamstats"&gt;&lt;CODE&gt;streamstats&lt;/CODE&gt;&lt;/A&gt; like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;yourBaseSearchHere 
| streamstats current=false last(STATUS) as last_status last(_time) as time_of_change by ID
| where STATUS!=last_status 
| eval duration=now()-time_of_change 
| eval duration=strftime(duration, "%H:%M") 
| table _time, HOSTNAME, ID, duration
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;this is un-tested since I'm missing the real events, so maybe you will need to adapt some things to match your needs.&lt;/P&gt;

&lt;P&gt;hope this helps ...&lt;/P&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
      <pubDate>Tue, 10 Jun 2014 11:06:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-quot-duration-quot-without-use-transaction/m-p/193885#M55880</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2014-06-10T11:06:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to get "duration" without use transaction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-quot-duration-quot-without-use-transaction/m-p/193886#M55881</link>
      <description>&lt;P&gt;Thank you for your comments.&lt;BR /&gt;
..Sorry for not explaining enough.&lt;/P&gt;

&lt;P&gt;"STATUS" column is included "Timeout" log.&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;DATE | ID | HOSTNAME | STATUS&lt;BR /&gt;
14/05/31 23:35 | user03 | PC02 | Start&lt;BR /&gt;
14/05/31 23:50 |  | PC02 | Timeout&lt;BR /&gt;
14/05/31 23:55 | user04 | PC02 | Start&lt;BR /&gt;
14/05/31 23:59 | user04 | PC02 | End&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;ID is not included in the log "Timeout".&lt;/P&gt;

&lt;P&gt;in this case, the use of time user03, until 23:50 there is a Timeout log from "STRAT" 23:35.&lt;/P&gt;

&lt;P&gt;I want to measure the PC usage time of each user in this case.&lt;/P&gt;

&lt;P&gt;I'm sorry for my clumsy English.&lt;BR /&gt;
It would be extremely helpful if you could tell me that.&lt;/P&gt;

&lt;P&gt;pisc&lt;/P&gt;</description>
      <pubDate>Wed, 11 Jun 2014 01:34:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-quot-duration-quot-without-use-transaction/m-p/193886#M55881</guid>
      <dc:creator>pisc</dc:creator>
      <dc:date>2014-06-11T01:34:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to get "duration" without use transaction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-quot-duration-quot-without-use-transaction/m-p/193887#M55882</link>
      <description>&lt;P&gt;try something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;yourBaseSearchHere 
| streamstats current=false last(STATUS) as last_status last(_time) as time_of_change by HOSTNAME
| where STATUS="Start" ( last_status="Timeout" OR last_status="End" )
| eval duration=now()-time_of_change 
| eval duration=strftime(duration, "%H:%M") 
| table _time, HOSTNAME, ID, duration
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;this will group your events by HOSTNAME and calculates the duration. The table will display the date, HOSTNAME, ID (if available) and the duration.&lt;/P&gt;

&lt;P&gt;hope this make sense&lt;/P&gt;</description>
      <pubDate>Wed, 11 Jun 2014 07:27:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-quot-duration-quot-without-use-transaction/m-p/193887#M55882</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2014-06-11T07:27:07Z</dc:date>
    </item>
  </channel>
</rss>

