<?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: Comparing field values(time) with Real Time and display the result in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Comparing-field-values-time-with-Real-Time-and-display-the/m-p/313544#M93873</link>
    <description>&lt;P&gt;@nnimbe...Based on whether your &lt;STRONG&gt;time&lt;/STRONG&gt; field is string time or epoch time you would require first eval to convert to epoch time or else not require the first eval with strptime:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;YourBaseSearch&amp;gt;
| eval time=strptime(time,"%m/%d/%Y %H:%M:%S")
| eval duration=(now()-time)/60
| search duration&amp;gt;24
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Following is run anywhere example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval time="12/28/2016 15:13:10"
| eval time=strptime(time,"%m/%d/%Y %H:%M:%S")
| eval duration=(now()-time)/60
| search duration&amp;gt;24
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You should also explain the scenario to provide some context around your question. The query will perform better if you can perform query filter based on date upfront rather than later.&lt;/P&gt;</description>
    <pubDate>Thu, 06 Apr 2017 09:29:40 GMT</pubDate>
    <dc:creator>niketn</dc:creator>
    <dc:date>2017-04-06T09:29:40Z</dc:date>
    <item>
      <title>Comparing field values(time) with Real Time and display the result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-field-values-time-with-Real-Time-and-display-the/m-p/313543#M93872</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;One of the field value in splunk is 12/28/2016 15:13:10, i just wanted to compare with realtime and display the results if the value of that field is greater than 24 hours(last 1 day), please let me know how to acheive the same&lt;/P&gt;

&lt;P&gt;example:time=12/28/2016 15:13:10, if it is &amp;gt;24hrs(last 1 day) with realtime then display the result&lt;/P&gt;</description>
      <pubDate>Thu, 06 Apr 2017 08:14:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-field-values-time-with-Real-Time-and-display-the/m-p/313543#M93872</guid>
      <dc:creator>nnimbe</dc:creator>
      <dc:date>2017-04-06T08:14:58Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing field values(time) with Real Time and display the result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-field-values-time-with-Real-Time-and-display-the/m-p/313544#M93873</link>
      <description>&lt;P&gt;@nnimbe...Based on whether your &lt;STRONG&gt;time&lt;/STRONG&gt; field is string time or epoch time you would require first eval to convert to epoch time or else not require the first eval with strptime:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;YourBaseSearch&amp;gt;
| eval time=strptime(time,"%m/%d/%Y %H:%M:%S")
| eval duration=(now()-time)/60
| search duration&amp;gt;24
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Following is run anywhere example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval time="12/28/2016 15:13:10"
| eval time=strptime(time,"%m/%d/%Y %H:%M:%S")
| eval duration=(now()-time)/60
| search duration&amp;gt;24
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You should also explain the scenario to provide some context around your question. The query will perform better if you can perform query filter based on date upfront rather than later.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Apr 2017 09:29:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-field-values-time-with-Real-Time-and-display-the/m-p/313544#M93873</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-04-06T09:29:40Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing field values(time) with Real Time and display the result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-field-values-time-with-Real-Time-and-display-the/m-p/313545#M93874</link>
      <description>&lt;P&gt;Thanks @niketnilay , it worked, meanwhile one more query&lt;/P&gt;

&lt;P&gt;I am just using metadata command to check the number of  hosts and sourcetype, if any new host or sourcetype is added to splunk i want to get alert, how to achieve this using search command (without uploading the csv file and comparing that...i am not looking for this option) &lt;/P&gt;</description>
      <pubDate>Thu, 06 Apr 2017 12:36:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-field-values-time-with-Real-Time-and-display-the/m-p/313545#M93874</guid>
      <dc:creator>nnimbe</dc:creator>
      <dc:date>2017-04-06T12:36:27Z</dc:date>
    </item>
  </channel>
</rss>

