<?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 Running an eval after a sub-search make my comparison negative in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Running-an-eval-after-a-sub-search-make-my-comparison-negative/m-p/558552#M158667</link>
    <description>&lt;P&gt;I am trying to make a comparison of one field against itself but from a previous day.&amp;nbsp; The use case is I'm trying to see if that value changes from day to day, the field is a file hash.&amp;nbsp; I sun a search for today and rename the field I want to compare then run a subsearch and rename the field again so I can then compare them after the subsearch finishes but the eval always evaluates to false and displays the last response you place in the eval line.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My code:&lt;/P&gt;&lt;P&gt;index=my_index RuleName="Monitor The File" FileName="file.exe" earliest="06/11/2021:00:00:00" latest="06/11/2021:24:00:00"&lt;BR /&gt;| rename FileHash as "todays_hash"&lt;BR /&gt;| append [ search&amp;nbsp;index=my_index RuleName="Monitor The File" FileName="file.exe" earliest="06/12/2021:00:00:00" latest="06/12/2021:24:00:00"&lt;BR /&gt;| rename FileHash as "yesterdays_hash"]&lt;BR /&gt;| eval description=case(todays_hash=yesterdays_hash,"Hash has not changed", todays_hash!=yesterdays_hash,"Hash has changed")&lt;BR /&gt;| table description todays_hash yesterdays_hash&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried changing the order of the eval putting != before == and it will always take the second options.&amp;nbsp; The table it showing the eval results and the 2 hashes.&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
    <pubDate>Wed, 07 Jul 2021 13:12:18 GMT</pubDate>
    <dc:creator>mybestfriendbob</dc:creator>
    <dc:date>2021-07-07T13:12:18Z</dc:date>
    <item>
      <title>Running an eval after a sub-search make my comparison negative</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Running-an-eval-after-a-sub-search-make-my-comparison-negative/m-p/558552#M158667</link>
      <description>&lt;P&gt;I am trying to make a comparison of one field against itself but from a previous day.&amp;nbsp; The use case is I'm trying to see if that value changes from day to day, the field is a file hash.&amp;nbsp; I sun a search for today and rename the field I want to compare then run a subsearch and rename the field again so I can then compare them after the subsearch finishes but the eval always evaluates to false and displays the last response you place in the eval line.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My code:&lt;/P&gt;&lt;P&gt;index=my_index RuleName="Monitor The File" FileName="file.exe" earliest="06/11/2021:00:00:00" latest="06/11/2021:24:00:00"&lt;BR /&gt;| rename FileHash as "todays_hash"&lt;BR /&gt;| append [ search&amp;nbsp;index=my_index RuleName="Monitor The File" FileName="file.exe" earliest="06/12/2021:00:00:00" latest="06/12/2021:24:00:00"&lt;BR /&gt;| rename FileHash as "yesterdays_hash"]&lt;BR /&gt;| eval description=case(todays_hash=yesterdays_hash,"Hash has not changed", todays_hash!=yesterdays_hash,"Hash has changed")&lt;BR /&gt;| table description todays_hash yesterdays_hash&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried changing the order of the eval putting != before == and it will always take the second options.&amp;nbsp; The table it showing the eval results and the 2 hashes.&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 07 Jul 2021 13:12:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Running-an-eval-after-a-sub-search-make-my-comparison-negative/m-p/558552#M158667</guid>
      <dc:creator>mybestfriendbob</dc:creator>
      <dc:date>2021-07-07T13:12:18Z</dc:date>
    </item>
    <item>
      <title>Re: Running an eval after a sub-search make my comparison negative</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Running-an-eval-after-a-sub-search-make-my-comparison-negative/m-p/558574#M158676</link>
      <description>&lt;P&gt;The append command creates separate events for the results of the subsearch.&amp;nbsp; IOW, the first set of events will contain a todays_hash field, but not a yesterdays_hash" field and the appended events will contain a yesterdays_hash field, but not a todays_hash field.&amp;nbsp; The solution is to use the stats command to combine the events on a common field.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=my_index RuleName="Monitor The File" FileName="file.exe" earliest="06/11/2021:00:00:00" latest="06/11/2021:24:00:00"
| rename FileHash as "yesterdays_hash"
| append [ search index=my_index RuleName="Monitor The File" 
  FileName="file.exe" earliest="06/12/2021:00:00:00" 
  latest="06/12/2021:24:00:00"
| rename FileHash as "todays_hash"]
| stats values(*) as * by FileName
| eval description=case(todays_hash=yesterdays_hash,"Hash has not changed", todays_hash!=yesterdays_hash,"Hash has changed")
| table FileName description todays_hash yesterdays_hash&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 07 Jul 2021 14:20:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Running-an-eval-after-a-sub-search-make-my-comparison-negative/m-p/558574#M158676</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2021-07-07T14:20:44Z</dc:date>
    </item>
    <item>
      <title>Re: Running an eval after a sub-search make my comparison negative</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Running-an-eval-after-a-sub-search-make-my-comparison-negative/m-p/558600#M158692</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/186952"&gt;@mybestfriendbob&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can try this also.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=my_index RuleName="Monitor The File" FileName="file.exe" earliest=-1d@d
| eval FileHash = if( _time&amp;gt;=relative_time(now(), "@d"),FileHash,null())
| eval PrevFileHash = if( _time&amp;lt;relative_time(now(), "@d"),FileHash,null())
| stats values(*) as * by FileName 
| eval description=case(FileHash=PrevFileHash,"Hash has not changed", FileHash!=PrevFileHash,"Hash has changed") 
| table FileName description FileHash PrevFileHash&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;BR /&gt;KV&lt;BR /&gt;▄︻̷̿┻̿═━一&lt;BR /&gt;&lt;BR /&gt;If any of my reply helps you to solve the problem Or gain knowledge, an upvote would be appreciated.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Jul 2021 16:48:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Running-an-eval-after-a-sub-search-make-my-comparison-negative/m-p/558600#M158692</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2021-07-07T16:48:22Z</dc:date>
    </item>
    <item>
      <title>Re: Running an eval after a sub-search make my comparison negative</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Running-an-eval-after-a-sub-search-make-my-comparison-negative/m-p/558688#M158730</link>
      <description>&lt;P&gt;That worked perfectly, thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jul 2021 13:31:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Running-an-eval-after-a-sub-search-make-my-comparison-negative/m-p/558688#M158730</guid>
      <dc:creator>mybestfriendbob</dc:creator>
      <dc:date>2021-07-08T13:31:49Z</dc:date>
    </item>
  </channel>
</rss>

