<?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 two field values for != in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Comparing-two-field-values-for/m-p/139778#M38480</link>
    <description>&lt;P&gt;Hello&lt;/P&gt;

&lt;P&gt;As you said, it will work with a join. But I think it will perform better using something like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source="syslog.log" OR source="syslog-prehash.log" | stats dc(source) as DCS by hash
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Previously you need to create an Alias of the original fields to "hash", so in both sources you have the same field name, and therefore the stats count by that common field works.&lt;/P&gt;

&lt;P&gt;Then you will get the results, if you get a "2" value, then the hash matches for that particular hash, if you a "1" value then you only have the hash from one of the sources, so no match.&lt;/P&gt;

&lt;P&gt;After that you could  filter the ones that doesn´t match, using: search DCS=1 &lt;/P&gt;

&lt;P&gt;Regards &lt;/P&gt;</description>
    <pubDate>Thu, 06 Feb 2014 12:02:56 GMT</pubDate>
    <dc:creator>gfuente</dc:creator>
    <dc:date>2014-02-06T12:02:56Z</dc:date>
    <item>
      <title>Comparing two field values for !=</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-two-field-values-for/m-p/139777#M38479</link>
      <description>&lt;P&gt;I'm trying to create a search comparing then validating two fields in Splunk... but struggling.&lt;/P&gt;

&lt;P&gt;My first search uses a lookup to add a field called sha256 to an event (what I'm doing is adding a hash to an event):&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;source="syslog.log" | lookup sha256 raw as _raw | fields sha256&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;I also have a set of the same events indexed in Splunk with the hashes already writtern under a field called: event_hash. &lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;source="syslog-prehash.log" | fields event_hash&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Note: Although we have two sets of the same events (lookup hash [syslog.log] / pre-hashed [syslog-prehas.log]) the event timestamps are slightly different because of the ways the pre-hashed events are written and indexed.&lt;/P&gt;

&lt;P&gt;Now I want to compare the field sha256 [syslog.log] and event_hash [syslog-prehash.log] to see if there are any hashes that do not match.&lt;/P&gt;

&lt;P&gt;As the fields (hashes) are alphanumeric I am struggling to find a way to do this. I'm thinking I could join the two searches and pipe a where command looking for hashes that only appear once (to show hashes that have no matches).&lt;/P&gt;

&lt;P&gt;Does anyone have any suggestions on a better way to write this search?&lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 06 Feb 2014 11:50:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-two-field-values-for/m-p/139777#M38479</guid>
      <dc:creator>himynamesdave</dc:creator>
      <dc:date>2014-02-06T11:50:42Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing two field values for !=</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-two-field-values-for/m-p/139778#M38480</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;

&lt;P&gt;As you said, it will work with a join. But I think it will perform better using something like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source="syslog.log" OR source="syslog-prehash.log" | stats dc(source) as DCS by hash
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Previously you need to create an Alias of the original fields to "hash", so in both sources you have the same field name, and therefore the stats count by that common field works.&lt;/P&gt;

&lt;P&gt;Then you will get the results, if you get a "2" value, then the hash matches for that particular hash, if you a "1" value then you only have the hash from one of the sources, so no match.&lt;/P&gt;

&lt;P&gt;After that you could  filter the ones that doesn´t match, using: search DCS=1 &lt;/P&gt;

&lt;P&gt;Regards &lt;/P&gt;</description>
      <pubDate>Thu, 06 Feb 2014 12:02:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-two-field-values-for/m-p/139778#M38480</guid>
      <dc:creator>gfuente</dc:creator>
      <dc:date>2014-02-06T12:02:56Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing two field values for !=</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-two-field-values-for/m-p/139779#M38481</link>
      <description>&lt;P&gt;may I ask why not use a simple&lt;/P&gt;

&lt;P&gt;source="syslog.log" OR source="syslog-prehash.log" | where sha256!=event_hash&lt;/P&gt;

&lt;P&gt;this should work as well&lt;/P&gt;</description>
      <pubDate>Thu, 06 Feb 2014 14:46:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-two-field-values-for/m-p/139779#M38481</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2014-02-06T14:46:42Z</dc:date>
    </item>
  </channel>
</rss>

