<?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: Need help in time difference for events in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Need-help-in-time-difference-for-events/m-p/480048#M140809</link>
    <description>&lt;P&gt;Sample:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval _raw="nodelabel,eventuei,Time_CST
GQML2-WANRTC001,uei.opennms.org/nodes/nodeUp,02/27/20 04:41:00
GQML2-WANRTC001,uei.opennms.org/nodes/nodeDown,02/27/20 04:40:00"
| multikv forceheader=1
| table nodelabel,eventuei,Time_CST
| eval Time_CST=strptime(Time_CST,"%m/%d/%y %T")
| fieldformat Time_CST=strftime(Time_CST,"%m/%d/%y %T")
| sort Time_CST
| delta Time_CST as duration
| eval duration=tostring(round(duration),"duration")
| rex field=eventuei "(?&amp;lt;Status&amp;gt;[A-Z].*)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;recommend:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=opennms nodelabel="GQML2-WANRTC001" "uei.opennms.org/nodes/nodeUp" OR "uei.opennms.org/nodes/nodeDown"
| eval Time_CST=_time
| sort Time_CST
| delta Time_CST as duration
| eval duration=tostring(round(duration),"duration")
| rex field=eventuei "(?&amp;lt;Status&amp;gt;[A-Z].*)"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 28 Feb 2020 12:35:41 GMT</pubDate>
    <dc:creator>to4kawa</dc:creator>
    <dc:date>2020-02-28T12:35:41Z</dc:date>
    <item>
      <title>Need help in time difference for events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-in-time-difference-for-events/m-p/480045#M140806</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;
&lt;P&gt;Pleas help me in getting a query to display the time difference from the events that mentioned below&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;index=opennms nodelabel="GQML2-WANRTC001" "uei.opennms.org/nodes/nodeUp" OR "uei.opennms.org/nodes/nodeDown"
 | rename _time as Time_CST 
 | sort - Time_CST
 | fieldformat Time_CST=strftime(Time_CST,"%x %X")
 | table nodelabel,eventuei,  Time_CST
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;output of the above query is&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;nodelabel   eventuei    Time_CST
GQML2-WANRTC001 uei.opennms.org/nodes/nodeUp    02/27/20 04:41:00
GQML2-WANRTC001 uei.opennms.org/nodes/nodeDown  02/27/20 04:40:00
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Another separate query I use.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;| rex field=eventuei "uei.opennms.org/nodes/node(?&amp;lt;State&amp;gt;.+)"
| rename _time as Time_CST
| fieldformat Time_CST=strftime(Time_CST,"%x %X")
| dedup nodelabel sortby - Time_CST 
| table nodelabel State  Time_CST
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Output for this query is&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt; nodelabel      State   Time_CST
GQML2-WANRTC001 UP  02/27/20 04:41:00
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Expected output is below is Up event came.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;nodelabel       Status  downtime
GQML2-WANRTC001 UP      00:01
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Expected output if Up event not came.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;nodelabel       Status  downtime
GQML2-WANRTC001 Down    
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Let me know all the possibilities of this.&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jun 2020 17:09:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-in-time-difference-for-events/m-p/480045#M140806</guid>
      <dc:creator>jerinvarghese</dc:creator>
      <dc:date>2020-06-15T17:09:48Z</dc:date>
    </item>
    <item>
      <title>Re: Need help in time difference for events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-in-time-difference-for-events/m-p/480046#M140807</link>
      <description>&lt;P&gt;Try this!&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(your search)
| transaction nodelabel startswith=eval(State="Down") endswith=eval(State="Up") keepevicted=true
| eval downtime=if(closed_txn=1,duration,null)
| eval downtime=tostring(downtime, "duration")
| fillnull value="" downtime
| eval Status=if(closed_txn=1,"Up","Down")
| table nodelabel,Status,downtime
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 27 Feb 2020 17:24:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-in-time-difference-for-events/m-p/480046#M140807</guid>
      <dc:creator>HiroshiSatoh</dc:creator>
      <dc:date>2020-02-27T17:24:03Z</dc:date>
    </item>
    <item>
      <title>Re: Need help in time difference for events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-in-time-difference-for-events/m-p/480047#M140808</link>
      <description>&lt;P&gt;HI Hiroshi,&lt;/P&gt;

&lt;P&gt;The code is not giving an output.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=opennms nodelabel="GQML2-WANRTC001" "uei.opennms.org/nodes/nodeUp" OR "uei.opennms.org/nodes/nodeDown"
 | rename _time as Time_CST 
 | sort - Time_CST
 | fieldformat Time_CST=strftime(Time_CST,"%x %X")
 | rex field=eventuei "uei.opennms.org/nodes/node(?&amp;lt;State&amp;gt;.+)"

 | eval downtime=if(closed_txn=1,duration,null)
 | eval downtime=tostring(downtime, "duration")
 | fillnull value="" downtime
 | eval Status=if(closed_txn=1,"Up","Down")
 | table nodelabel,Status,downtime
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;output:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;nodelabel   Status  downtime
GQML2-WANRTC001 Down    
GQML2-WANRTC001 Down    
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;when am adding the transaction line, no output is there.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=opennms nodelabel="GQML2-WANRTC001" "uei.opennms.org/nodes/nodeUp" OR "uei.opennms.org/nodes/nodeDown"
 | rename _time as Time_CST 
 | sort - Time_CST
 | fieldformat Time_CST=strftime(Time_CST,"%x %X")
 | rex field=eventuei "uei.opennms.org/nodes/node(?&amp;lt;State&amp;gt;.+)"
| transaction nodelabel startswith=eval(State="Down") endswith=eval(State="Up") keepevicted=true
 | eval downtime=if(closed_txn=1,duration,null)
 | eval downtime=tostring(downtime, "duration")
 | fillnull value="" downtime
 | eval Status=if(closed_txn=1,"Up","Down")
 | table nodelabel,Status,downtime
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 28 Feb 2020 09:32:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-in-time-difference-for-events/m-p/480047#M140808</guid>
      <dc:creator>jerinvarghese</dc:creator>
      <dc:date>2020-02-28T09:32:57Z</dc:date>
    </item>
    <item>
      <title>Re: Need help in time difference for events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-in-time-difference-for-events/m-p/480048#M140809</link>
      <description>&lt;P&gt;Sample:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval _raw="nodelabel,eventuei,Time_CST
GQML2-WANRTC001,uei.opennms.org/nodes/nodeUp,02/27/20 04:41:00
GQML2-WANRTC001,uei.opennms.org/nodes/nodeDown,02/27/20 04:40:00"
| multikv forceheader=1
| table nodelabel,eventuei,Time_CST
| eval Time_CST=strptime(Time_CST,"%m/%d/%y %T")
| fieldformat Time_CST=strftime(Time_CST,"%m/%d/%y %T")
| sort Time_CST
| delta Time_CST as duration
| eval duration=tostring(round(duration),"duration")
| rex field=eventuei "(?&amp;lt;Status&amp;gt;[A-Z].*)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;recommend:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=opennms nodelabel="GQML2-WANRTC001" "uei.opennms.org/nodes/nodeUp" OR "uei.opennms.org/nodes/nodeDown"
| eval Time_CST=_time
| sort Time_CST
| delta Time_CST as duration
| eval duration=tostring(round(duration),"duration")
| rex field=eventuei "(?&amp;lt;Status&amp;gt;[A-Z].*)"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 28 Feb 2020 12:35:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-in-time-difference-for-events/m-p/480048#M140809</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-02-28T12:35:41Z</dc:date>
    </item>
    <item>
      <title>Re: Need help in time difference for events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-in-time-difference-for-events/m-p/480049#M140810</link>
      <description>&lt;P&gt;Because there is no _time.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=opennms nodelabel="GQML2-WANRTC001" "uei.opennms.org/nodes/nodeUp" OR "uei.opennms.org/nodes/nodeDown"
  | rex field=eventuei "uei.opennms.org/nodes/node(?&amp;lt;State&amp;gt;.+)"
 | transaction nodelabel startswith=eval(State="Down") endswith=eval(State="Up") keepevicted=true
  | eval downtime=if(closed_txn=1,duration,null)
  | eval downtime=tostring(downtime, "duration")
  | fillnull value="" downtime
  | eval Status=if(closed_txn=1,"Up","Down")
  | table nodelabel,Status,downtime
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 28 Feb 2020 15:37:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-in-time-difference-for-events/m-p/480049#M140810</guid>
      <dc:creator>HiroshiSatoh</dc:creator>
      <dc:date>2020-02-28T15:37:04Z</dc:date>
    </item>
    <item>
      <title>Re: Need help in time difference for events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-in-time-difference-for-events/m-p/480050#M140811</link>
      <description>&lt;P&gt;Hi Hiroshi,&lt;/P&gt;

&lt;P&gt;One more help,&lt;BR /&gt;
My output comes as below&lt;BR /&gt;
    GQPCW-WANINF001 Up  00:15:40.019&lt;BR /&gt;
    SGSNGSS13-WLNSGW001 Up  00:04:18.466&lt;BR /&gt;
    NGUSN-LANCUA018 Up  00:00:30.598&lt;/P&gt;

&lt;P&gt;am getting that micro second also,&lt;BR /&gt;
please help in removing that value and keep it as HH:MM:SS&lt;/P&gt;

&lt;P&gt;and also is it possible to show only contents that duration is above 15 mins. like whatever below 15 mins should be ignored or not displayed. &lt;/P&gt;</description>
      <pubDate>Tue, 24 Mar 2020 09:57:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-in-time-difference-for-events/m-p/480050#M140811</guid>
      <dc:creator>jerinvarghese</dc:creator>
      <dc:date>2020-03-24T09:57:50Z</dc:date>
    </item>
    <item>
      <title>Re: Need help in time difference for events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-in-time-difference-for-events/m-p/480051#M140812</link>
      <description>&lt;P&gt;Current code that am using based on your suggestion..&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=opennms "uei.opennms.org/nodes/nodeUp" OR "uei.opennms.org/nodes/nodeDown" AND "AOKBT-WANRTC002"
 | eval Time_CST=_time
 | sort Time_CST
 | delta Time_CST as duration
 | eval duration=tostring(round(duration),"duration")
 | fieldformat Time_CST=strftime(Time_CST,"%x %X")
 | rex field=eventuei "(?&amp;lt;Status&amp;gt;[A-Z].*)"
 | dedup nodelabel sortby - Time_CST 
 | table nodelabel, duration, Status, Time_CST
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Output is...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;nodelabel   duration    Status  Time_CST
AOKBT-WANRTC002 00:15:38    Up  03/23/20 10:01:22
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If i keep it for all devices, I used to get duration for 1 min also.. please help me filter or remove all those below 15 mins. I want to display only those devices with duration above 15 mins.&lt;BR /&gt;
please help me&lt;/P&gt;</description>
      <pubDate>Tue, 24 Mar 2020 10:23:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-in-time-difference-for-events/m-p/480051#M140812</guid>
      <dc:creator>jerinvarghese</dc:creator>
      <dc:date>2020-03-24T10:23:40Z</dc:date>
    </item>
    <item>
      <title>Re: Need help in time difference for events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-in-time-difference-for-events/m-p/480052#M140813</link>
      <description>&lt;PRE&gt;&lt;CODE&gt; ....
 | delta Time_CST as duration
 | where duration &amp;gt; 9000
....
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 26 Mar 2020 10:24:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-in-time-difference-for-events/m-p/480052#M140813</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-03-26T10:24:20Z</dc:date>
    </item>
  </channel>
</rss>

