<?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 subtract _time field from Multifield value in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-time-field-from-Multifield-value/m-p/473774#M133310</link>
    <description>&lt;P&gt;@zhonk &lt;/P&gt;

&lt;P&gt;Did you check individually -- query debug&lt;/P&gt;

&lt;P&gt;are u getting Heart Beat epoch and _time epoch converting or not..&lt;/P&gt;</description>
    <pubDate>Fri, 17 Apr 2020 11:35:21 GMT</pubDate>
    <dc:creator>harishalipaka</dc:creator>
    <dc:date>2020-04-17T11:35:21Z</dc:date>
    <item>
      <title>How to subtract _time field from Multifield value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-time-field-from-Multifield-value/m-p/473768#M133304</link>
      <description>&lt;P&gt;Hello I have a search with an MV Value this is called HeartBeatTime. I like to create an allert when the HeartBeatTime is over 5 Minute. My question is how can I get the time diff about _time and HeartBeatTime?&lt;/P&gt;

&lt;P&gt;Here is my search:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;&lt;BR /&gt;
index=&lt;EM&gt;temp host="ctw-prod-qa" &lt;BR /&gt;
| rex max_match=5 "serviceUserName=\"(?[^\"]&lt;/EM&gt;)" &lt;BR /&gt;
| rex max_match=5 "serviceIPAddress=\"(?[^\"]&lt;EM&gt;)" &lt;BR /&gt;
| rex max_match=5 "serviceStartupTime=\"(?[^\"]&lt;/EM&gt;)" &lt;BR /&gt;
| rex max_match=5 "serviceStatus=\"(?[^\"]&lt;EM&gt;)" &lt;BR /&gt;
| rex max_match=5 "serviceHeartBeatTime=\"(?[^\"]&lt;/EM&gt;)" &lt;BR /&gt;
| eval User_Number = mvcount(UserName) &lt;BR /&gt;
| eval TimeDiff=_time - strptime(HeartBeatTime,"%Y-%m-%d %H:%M:%S.%3N")&lt;BR /&gt;
| table _time,UserName,Status, HeartBeatTime,TimeDiff, IPAddress, User_Number &lt;BR /&gt;
| eval final_User_Number=if(isnotnull(User_Number),User_Number,0)&lt;BR /&gt;
&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 04:58:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-time-field-from-Multifield-value/m-p/473768#M133304</guid>
      <dc:creator>zhonk</dc:creator>
      <dc:date>2020-09-30T04:58:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to subtract _time field from Multifield value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-time-field-from-Multifield-value/m-p/473769#M133305</link>
      <description>&lt;P&gt;hi @zhonk&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Updated my Answer Please try like below&lt;/STRONG&gt; @zhonk &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|makeresults |eval HeartBeatTime="2020-04-16 12:23:32.9",heartbeatEpoch=strptime(HeartBeatTime,"%Y-%m-%d %H:%M:%S.%3N"),Time=_time|eval TimeDiff=Time-heartbeatEpoch,diff=tostring(TimeDiff,"Duration")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 17 Apr 2020 08:36:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-time-field-from-Multifield-value/m-p/473769#M133305</guid>
      <dc:creator>harishalipaka</dc:creator>
      <dc:date>2020-04-17T08:36:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to subtract _time field from Multifield value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-time-field-from-Multifield-value/m-p/473770#M133306</link>
      <description>&lt;P&gt;Hi @harishalipaka i have change the code but the field TimeDiff is empty.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Apr 2020 08:52:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-time-field-from-Multifield-value/m-p/473770#M133306</guid>
      <dc:creator>zhonk</dc:creator>
      <dc:date>2020-04-17T08:52:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to subtract _time field from Multifield value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-time-field-from-Multifield-value/m-p/473771#M133307</link>
      <description>&lt;P&gt;What's your Splunk version?&lt;BR /&gt;
some multivalue function need version 8.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Apr 2020 10:53:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-time-field-from-Multifield-value/m-p/473771#M133307</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-04-17T10:53:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to subtract _time field from Multifield value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-time-field-from-Multifield-value/m-p/473772#M133308</link>
      <description>&lt;P&gt;Hi @to4kawa our splunk version is 7.3.4.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Apr 2020 11:31:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-time-field-from-Multifield-value/m-p/473772#M133308</guid>
      <dc:creator>zhonk</dc:creator>
      <dc:date>2020-04-17T11:31:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to subtract _time field from Multifield value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-time-field-from-Multifield-value/m-p/473773#M133309</link>
      <description>&lt;P&gt;your  &lt;CODE&gt;|eval TimeDiff=_tmie - sp...&lt;/CODE&gt; can't work, because HeartBeatTime is multivalue.&lt;BR /&gt;
Correcting query is difficult, will you provide logs?&lt;/P&gt;</description>
      <pubDate>Fri, 17 Apr 2020 11:35:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-time-field-from-Multifield-value/m-p/473773#M133309</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-04-17T11:35:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to subtract _time field from Multifield value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-time-field-from-Multifield-value/m-p/473774#M133310</link>
      <description>&lt;P&gt;@zhonk &lt;/P&gt;

&lt;P&gt;Did you check individually -- query debug&lt;/P&gt;

&lt;P&gt;are u getting Heart Beat epoch and _time epoch converting or not..&lt;/P&gt;</description>
      <pubDate>Fri, 17 Apr 2020 11:35:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-time-field-from-Multifield-value/m-p/473774#M133310</guid>
      <dc:creator>harishalipaka</dc:creator>
      <dc:date>2020-04-17T11:35:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to subtract _time field from Multifield value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-time-field-from-Multifield-value/m-p/473775#M133311</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;
it works now, with a little trick.&lt;/P&gt;

&lt;P&gt;With mvzip I create one field with all Multivalues and after that I expand it. So I get for each UserName one line and can make the Diff calc.&lt;BR /&gt;
Here is my new Code:&lt;/P&gt;

&lt;P&gt;index=&lt;EM&gt;temp host="ctw-prod-qa" &lt;BR /&gt;
| rex max_match=5 "serviceUserName=\"(?[^\"]&lt;/EM&gt;)" &lt;BR /&gt;
| rex max_match=5 "serviceStatus=\"(?[^\"]&lt;EM&gt;)" &lt;BR /&gt;
| rex max_match=5 "serviceIPAddress=\"(?[^\"]&lt;/EM&gt;)" &lt;BR /&gt;
| rex max_match=5 "serviceHeartBeatTime=\"(?[^\"]&lt;EM&gt;)" &lt;BR /&gt;
| rex max_match=5 "serviceStartupTime=\"(?[^\"]&lt;/EM&gt;)" &lt;BR /&gt;
| eval HeartBeatTime=if(isnotnull(HeartBeatTime),HeartBeatTime,"1970-01-01 01:00:00.000")&lt;/P&gt;

&lt;P&gt;| eval User_Number = mvcount(UserName)&lt;BR /&gt;
| eval final_User_Number=if(isnotnull(User_Number),User_Number,0)&lt;BR /&gt;
| eval Feld1 = mvzip(UserName,HeartBeatTime)&lt;BR /&gt;&lt;BR /&gt;
| eval Feld1 = mvzip(Feld1,Status) &lt;BR /&gt;
| eval Feld1 = mvzip(Feld1,IPAddress) &lt;BR /&gt;
| eval Feld1 = mvzip(Feld1,Startuptime)&lt;BR /&gt;
| mvexpand Feld1&lt;BR /&gt;
| rex field=Feld1 "(?\w*),(?\S*\s*\S*),(?\w*),(?\S*),(?\S*\s*\S*)" &lt;/P&gt;

&lt;P&gt;| eval Time=_time &lt;BR /&gt;
|eval heartbeaepoch=strptime(HeartBeatTime,"%Y-%m-%d %H:%M:%S.%3N")&lt;BR /&gt;
| eval TimeDiff=Time - heartbeaepoch&lt;BR /&gt;
| table _time, UserName,Startuptime , HeartBeatTime,Status,IPAddress,TimeDiff, User_Number, final_User_Number&lt;/P&gt;

&lt;P&gt;Thanks &lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 05:02:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-time-field-from-Multifield-value/m-p/473775#M133311</guid>
      <dc:creator>zhonk</dc:creator>
      <dc:date>2020-09-30T05:02:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to subtract _time field from Multifield value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-time-field-from-Multifield-value/m-p/473776#M133312</link>
      <description>&lt;P&gt;@zhonk If your problem is resolved then please accept an answer to help future readers.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Apr 2020 12:05:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-time-field-from-Multifield-value/m-p/473776#M133312</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2020-04-17T12:05:26Z</dc:date>
    </item>
  </channel>
</rss>

