<?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: using eval to calculate time between events not working in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/using-eval-to-calculate-time-between-events-not-working/m-p/418982#M191003</link>
    <description>&lt;P&gt;@MuS  Thanks, this works. I now only have to convert to normal time, because I get a number as result. Is there a way to show one line per ID? What I mean is that in the example I gave there are always tow events per ID. Ik want one line per ID. &lt;/P&gt;</description>
    <pubDate>Wed, 31 Jul 2019 11:01:22 GMT</pubDate>
    <dc:creator>Mike6960</dc:creator>
    <dc:date>2019-07-31T11:01:22Z</dc:date>
    <item>
      <title>using eval to calculate time between events not working</title>
      <link>https://community.splunk.com/t5/Splunk-Search/using-eval-to-calculate-time-between-events-not-working/m-p/418980#M191001</link>
      <description>&lt;P&gt;I am trying to use eval to calculate the time between events. Those events have a unique ID.&lt;BR /&gt;
This is the sarch that I have now:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; &amp;lt;my search&amp;gt; 
| eval Test =if(message.information=="some_data",_time,null()) 
| eval Test2=if(message.information="some_data_2" ,_time,null()) 
| eval Test3 = Test - Test2 
| table _time Test Test2 Test3
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I am doing something wrong I guess because I only see values in the _time column, the rest is empty.&lt;BR /&gt;
&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/7422iC634189317552010/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jul 2019 10:15:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/using-eval-to-calculate-time-between-events-not-working/m-p/418980#M191001</guid>
      <dc:creator>Mike6960</dc:creator>
      <dc:date>2019-07-31T10:15:21Z</dc:date>
    </item>
    <item>
      <title>Re: using eval to calculate time between events not working</title>
      <link>https://community.splunk.com/t5/Splunk-Search/using-eval-to-calculate-time-between-events-not-working/m-p/418981#M191002</link>
      <description>&lt;P&gt;Hi Mike6960,&lt;/P&gt;

&lt;P&gt;you need to put your &lt;CODE&gt;message.information&lt;/CODE&gt; fields in single quotes &lt;CODE&gt;'&lt;/CODE&gt; like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;my search&amp;gt; 
 | eval Test =if('message.information'=="some_data",_time,null()) 
 | eval Test2=if('message.information'="some_data_2" ,_time,null()) 
 | eval Test3 = Test - Test2 
 | table _time Test Test2 Test3
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;because they contain a &lt;CODE&gt;.&lt;/CODE&gt; and this is a special case when using &lt;CODE&gt;eval()&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Take a look at this run everywhere SPL:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval message.information="1", foo="2" 
| eval Test =if('message.information'=="1",now(),null()) 
| eval Test2=if('message.information'=="2" ,null(),relative_time(now(), "-1sec")) 
| eval Test3 = Test - Test2 
| table _time Test Test2 Test3
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hope this helps ...&lt;/P&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jul 2019 10:25:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/using-eval-to-calculate-time-between-events-not-working/m-p/418981#M191002</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2019-07-31T10:25:19Z</dc:date>
    </item>
    <item>
      <title>Re: using eval to calculate time between events not working</title>
      <link>https://community.splunk.com/t5/Splunk-Search/using-eval-to-calculate-time-between-events-not-working/m-p/418982#M191003</link>
      <description>&lt;P&gt;@MuS  Thanks, this works. I now only have to convert to normal time, because I get a number as result. Is there a way to show one line per ID? What I mean is that in the example I gave there are always tow events per ID. Ik want one line per ID. &lt;/P&gt;</description>
      <pubDate>Wed, 31 Jul 2019 11:01:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/using-eval-to-calculate-time-between-events-not-working/m-p/418982#M191003</guid>
      <dc:creator>Mike6960</dc:creator>
      <dc:date>2019-07-31T11:01:22Z</dc:date>
    </item>
    <item>
      <title>Re: using eval to calculate time between events not working</title>
      <link>https://community.splunk.com/t5/Splunk-Search/using-eval-to-calculate-time-between-events-not-working/m-p/418983#M191004</link>
      <description>&lt;P&gt;@MuS , also the field Test3 remains empty...&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jul 2019 11:04:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/using-eval-to-calculate-time-between-events-not-working/m-p/418983#M191004</guid>
      <dc:creator>Mike6960</dc:creator>
      <dc:date>2019-07-31T11:04:20Z</dc:date>
    </item>
    <item>
      <title>Re: using eval to calculate time between events not working</title>
      <link>https://community.splunk.com/t5/Splunk-Search/using-eval-to-calculate-time-between-events-not-working/m-p/418984#M191005</link>
      <description>&lt;P&gt;Sorry, but there is no &lt;CODE&gt;id&lt;/CODE&gt; in this question and I also don't know what your events &lt;EM&gt;look&lt;/EM&gt; like or your expected output looks like. This is really up to you to figure it out or accept this answer and post a new one with more details.&lt;/P&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jul 2019 11:06:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/using-eval-to-calculate-time-between-events-not-working/m-p/418984#M191005</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2019-07-31T11:06:41Z</dc:date>
    </item>
    <item>
      <title>Re: using eval to calculate time between events not working</title>
      <link>https://community.splunk.com/t5/Splunk-Search/using-eval-to-calculate-time-between-events-not-working/m-p/418985#M191006</link>
      <description>&lt;P&gt;Ok, thank you for your help with my initial question&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jul 2019 11:10:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/using-eval-to-calculate-time-between-events-not-working/m-p/418985#M191006</guid>
      <dc:creator>Mike6960</dc:creator>
      <dc:date>2019-07-31T11:10:11Z</dc:date>
    </item>
    <item>
      <title>Re: using eval to calculate time between events not working</title>
      <link>https://community.splunk.com/t5/Splunk-Search/using-eval-to-calculate-time-between-events-not-working/m-p/418986#M191007</link>
      <description>&lt;P&gt;You're welcome &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jul 2019 11:18:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/using-eval-to-calculate-time-between-events-not-working/m-p/418986#M191007</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2019-07-31T11:18:46Z</dc:date>
    </item>
  </channel>
</rss>

