<?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 Using eval with table in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Using-eval-with-table/m-p/50905#M12238</link>
    <description>&lt;P&gt;I have a log by the name of auditlog, which  logs accountNumber AND   accountCreateDt&lt;/P&gt;

&lt;P&gt;accountCreateDt = %Y-%m-%d format. &lt;/P&gt;

&lt;P&gt;I am trying to identify Accounts that were created less than 24 hours ago by executing this search.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="auditlog" | convert timeformat="%Y-%m-%d" mktime(accountCreateDt) as lastTime | convert mktime(_time) as c_time | eval Diff=c_time - lastTime | where Diff &amp;lt; 86400 | table accountNumber 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;For some reason, this query is not working.&lt;/P&gt;

&lt;P&gt;IF i replace the last query with &lt;CODE&gt;| table Diff&lt;/CODE&gt; it works like a charm (it gives me all time difference as long as account was created less than 24 hours ago).&lt;/P&gt;

&lt;P&gt;Am i not using eval and table correctly ?&lt;/P&gt;</description>
    <pubDate>Fri, 30 Nov 2012 22:55:09 GMT</pubDate>
    <dc:creator>asarolkar</dc:creator>
    <dc:date>2012-11-30T22:55:09Z</dc:date>
    <item>
      <title>Using eval with table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Using-eval-with-table/m-p/50905#M12238</link>
      <description>&lt;P&gt;I have a log by the name of auditlog, which  logs accountNumber AND   accountCreateDt&lt;/P&gt;

&lt;P&gt;accountCreateDt = %Y-%m-%d format. &lt;/P&gt;

&lt;P&gt;I am trying to identify Accounts that were created less than 24 hours ago by executing this search.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="auditlog" | convert timeformat="%Y-%m-%d" mktime(accountCreateDt) as lastTime | convert mktime(_time) as c_time | eval Diff=c_time - lastTime | where Diff &amp;lt; 86400 | table accountNumber 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;For some reason, this query is not working.&lt;/P&gt;

&lt;P&gt;IF i replace the last query with &lt;CODE&gt;| table Diff&lt;/CODE&gt; it works like a charm (it gives me all time difference as long as account was created less than 24 hours ago).&lt;/P&gt;

&lt;P&gt;Am i not using eval and table correctly ?&lt;/P&gt;</description>
      <pubDate>Fri, 30 Nov 2012 22:55:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Using-eval-with-table/m-p/50905#M12238</guid>
      <dc:creator>asarolkar</dc:creator>
      <dc:date>2012-11-30T22:55:09Z</dc:date>
    </item>
    <item>
      <title>Re: Using eval with table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Using-eval-with-table/m-p/50906#M12239</link>
      <description>&lt;P&gt;It looks mostly okay, but I think you are doing it the hard way:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=auditlog
| eval lastTime = strptime(accountCreateDt,"%Y-%m-%d")
| where lastTime &amp;gt; relative_time(now(), "-24h")
| table accountNumber accountCreateDt
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;One of the variables that you are using is &lt;CODE&gt;_time&lt;/CODE&gt; - that is the the timestamp of the event; it will vary with each event. &lt;CODE&gt;now()&lt;/CODE&gt; is the starting time of the search.  I think that &lt;CODE&gt;now()&lt;/CODE&gt; is what you should be using here, no matter how you choose to calculate things.&lt;/P&gt;</description>
      <pubDate>Fri, 30 Nov 2012 23:12:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Using-eval-with-table/m-p/50906#M12239</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2012-11-30T23:12:39Z</dc:date>
    </item>
    <item>
      <title>Re: Using eval with table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Using-eval-with-table/m-p/50907#M12240</link>
      <description>&lt;P&gt;I like the idea of using now() more than _time.&lt;/P&gt;

&lt;P&gt;Also this is a much simpler solution&lt;/P&gt;</description>
      <pubDate>Sat, 01 Dec 2012 00:16:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Using-eval-with-table/m-p/50907#M12240</guid>
      <dc:creator>asarolkar</dc:creator>
      <dc:date>2012-12-01T00:16:58Z</dc:date>
    </item>
  </channel>
</rss>

