<?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 different fields in different events to each other in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Comparing-different-fields-in-different-events-to-each-other/m-p/123317#M33297</link>
    <description>&lt;P&gt;And finally.... success. I did not use "null" in as you did in your example in the "ifs". I thought by tagging those nulls it was fixing a problem in my data which was borking the entire search. Turns out, a few fillnulls earlier in the search had solved the issue.&lt;/P&gt;

&lt;P&gt;Therefor, returning the nulls back into the following prevented the" Alert1_FieldA" and "Alert2_FieldC" from becoming multi value fields, allowing the where comparison to work as you had originally proposed:&lt;/P&gt;

&lt;P&gt;| eval Alert1_FieldA=if(alert="ONE", fieldA, null())&lt;BR /&gt;
| eval Alert2_FieldC=if(alert="TWO", fieldC, null())&lt;/P&gt;

&lt;P&gt;Thanks again!&lt;/P&gt;</description>
    <pubDate>Mon, 28 Sep 2020 17:35:59 GMT</pubDate>
    <dc:creator>thisissplunk</dc:creator>
    <dc:date>2020-09-28T17:35:59Z</dc:date>
    <item>
      <title>Comparing different fields in different events to each other</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-different-fields-in-different-events-to-each-other/m-p/123310#M33290</link>
      <description>&lt;P&gt;This is the question I need to answer with Splunk:&lt;/P&gt;

&lt;P&gt;"How can I determine when different unique events with &lt;STRONG&gt;alert="ONE"&lt;/STRONG&gt; or &lt;STRONG&gt;alert="TWO"&lt;/STRONG&gt; fire within 1 second of each other, where their hostname field is the same? &lt;STRONG&gt;&lt;EM&gt;AND&lt;/EM&gt;&lt;/STRONG&gt; where event alert="ONE"s field "A", matches event alert="TWO"s field "C"?&lt;/P&gt;

&lt;P&gt;My normal solution for the first sentence is easy:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=logs sourcetype=host_log alert="ONE" OR alert="TWO" | transaction fields="hostname" maxspan=1s |  | eval UniqueCount=mvcount(alert) | where UniqueCount &amp;gt; 1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But I cannot for the life of me figure out how to compare them after this point. I need to do something like you'd see in code here:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;if ONE[field_A] = TWO[field_C] then show transaction event
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I'm also not sure if the transaction command is the best way to go about this. I tried a subsearch but that loses the keying off of hostname within 1 second of each other, which is crucial here.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Sep 2014 18:34:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-different-fields-in-different-events-to-each-other/m-p/123310#M33290</guid>
      <dc:creator>thisissplunk</dc:creator>
      <dc:date>2014-09-12T18:34:14Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing different fields in different events to each other</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-different-fields-in-different-events-to-each-other/m-p/123311#M33291</link>
      <description>&lt;P&gt;You should be able to do this with some &lt;STRONG&gt;eval&lt;/STRONG&gt; statements.  First, eval field_A from the event where alert="ONE" and field_B from the event where alert="TWO" into something you can recognize after your transaction command:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=logs sourcetype=host_log alert="ONE" OR alert="TWO"
| eval Alert1_FieldA=if(alert="ONE", fieldA, null())
| eval Alert2_FieldC=if(alert="TWO", fieldC, null())
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then perform your transaction.  &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| transaction fields="hostname" maxspan=1s 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;After the transaction, eval a test to see if the event is something your looking for or not, then search for the ones you want:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval Keep_Or_Not=if(Alert1_FieldA=Alert2FieldC, "Keep", "Do_Not_Keep")
| search Keep_Or_Not="Keep"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So the complete search would look like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=logs sourcetype=host_log alert="ONE" OR alert="TWO"
| eval Alert1_FieldA=if(alert="ONE", fieldA, null())
| eval Alert2_FieldC=if(alert="TWO", fieldC, null())
| transaction fields="hostname" maxspan=1s 
| eval Keep_Or_Not=if(Alert1_FieldA=Alert2_FieldC, "Keep", "Do_Not_Keep")
| search Keep_Or_Not="Keep"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 28 Sep 2020 17:34:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-different-fields-in-different-events-to-each-other/m-p/123311#M33291</guid>
      <dc:creator>wpreston</dc:creator>
      <dc:date>2020-09-28T17:34:29Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing different fields in different events to each other</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-different-fields-in-different-events-to-each-other/m-p/123312#M33292</link>
      <description>&lt;P&gt;you could try to create the transactions first then use a 3rd field to compare the 2 events and use a where statement to only show when A and B match.&lt;/P&gt;

&lt;P&gt;| transaction startswith=("whatever starts") endswith=("whatever ends") | eval THIRDFIELD=case(fieldA=fieldB,1,fieldA!=fieldB,0) |  where THIRDFIELD=1 | table fields&lt;/P&gt;</description>
      <pubDate>Fri, 12 Sep 2014 19:17:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-different-fields-in-different-events-to-each-other/m-p/123312#M33292</guid>
      <dc:creator>jeffflynn</dc:creator>
      <dc:date>2014-09-12T19:17:32Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing different fields in different events to each other</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-different-fields-in-different-events-to-each-other/m-p/123313#M33293</link>
      <description>&lt;P&gt;This was great thanks! That said, the last eval and search statement does not work! But if I replace them with this it does:&lt;/P&gt;

&lt;P&gt;| top limit=0 Alert1_FieldA, Alert2FieldC&lt;BR /&gt;
| where Alert1_FieldA==Alert2FieldC&lt;/P&gt;

&lt;P&gt;Any ideas? The fact that I can get this far is enough, but I'm not sure why your last two statements along with the where command I tried does not work....&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 17:34:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-different-fields-in-different-events-to-each-other/m-p/123313#M33293</guid>
      <dc:creator>thisissplunk</dc:creator>
      <dc:date>2020-09-28T17:34:31Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing different fields in different events to each other</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-different-fields-in-different-events-to-each-other/m-p/123314#M33294</link>
      <description>&lt;P&gt;It looks like I have a typo in the answer, (I forgot to put the underscore in Alert2_FieldC in the last &lt;STRONG&gt;eval&lt;/STRONG&gt; statement) sorry about that!   I'll fix it in the above search.&lt;/P&gt;</description>
      <pubDate>Sat, 13 Sep 2014 00:54:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-different-fields-in-different-events-to-each-other/m-p/123314#M33294</guid>
      <dc:creator>wpreston</dc:creator>
      <dc:date>2014-09-13T00:54:32Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing different fields in different events to each other</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-different-fields-in-different-events-to-each-other/m-p/123315#M33295</link>
      <description>&lt;P&gt;There is still an issue. All transactions eval out to "Do_Not_Keep" event though one should be "Keep". What I posted above your last comment works, and this works as well for some reason I do not understand:&lt;/P&gt;

&lt;P&gt;| eval tmp=lower(if(isnull(Alert1_FieldA),Alert2_FieldC,Alert1_FieldA))&lt;BR /&gt;
| transaction maxspan=1m hostname tmp&lt;BR /&gt;
| where Alert1_FieldA==Alert2_FieldC&lt;/P&gt;

&lt;P&gt;This also works:&lt;/P&gt;

&lt;P&gt;| stats count by NewStartupSourceProcess, JavaEnvelopeHipsFiles&lt;BR /&gt;
| where NewStartupSourceProcess==JavaEnvelopeHipsFiles&lt;/P&gt;

&lt;P&gt;I'd much rather have access to the full event though.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 17:35:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-different-fields-in-different-events-to-each-other/m-p/123315#M33295</guid>
      <dc:creator>thisissplunk</dc:creator>
      <dc:date>2020-09-28T17:35:53Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing different fields in different events to each other</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-different-fields-in-different-events-to-each-other/m-p/123316#M33296</link>
      <description>&lt;P&gt;So I've realized the problem is because the Alert1_FieldA and Alert2_FieldC are multi value fields at the point of comparison. Not sure how to compare them besides mvjoin'ing them and doing some extraneous matching. Is there a better way?&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 17:35:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-different-fields-in-different-events-to-each-other/m-p/123316#M33296</guid>
      <dc:creator>thisissplunk</dc:creator>
      <dc:date>2020-09-28T17:35:56Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing different fields in different events to each other</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-different-fields-in-different-events-to-each-other/m-p/123317#M33297</link>
      <description>&lt;P&gt;And finally.... success. I did not use "null" in as you did in your example in the "ifs". I thought by tagging those nulls it was fixing a problem in my data which was borking the entire search. Turns out, a few fillnulls earlier in the search had solved the issue.&lt;/P&gt;

&lt;P&gt;Therefor, returning the nulls back into the following prevented the" Alert1_FieldA" and "Alert2_FieldC" from becoming multi value fields, allowing the where comparison to work as you had originally proposed:&lt;/P&gt;

&lt;P&gt;| eval Alert1_FieldA=if(alert="ONE", fieldA, null())&lt;BR /&gt;
| eval Alert2_FieldC=if(alert="TWO", fieldC, null())&lt;/P&gt;

&lt;P&gt;Thanks again!&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 17:35:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-different-fields-in-different-events-to-each-other/m-p/123317#M33297</guid>
      <dc:creator>thisissplunk</dc:creator>
      <dc:date>2020-09-28T17:35:59Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing different fields in different events to each other</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-different-fields-in-different-events-to-each-other/m-p/123318#M33298</link>
      <description>&lt;P&gt;Ah, excellent, glad you found that!&lt;/P&gt;</description>
      <pubDate>Tue, 16 Sep 2014 18:50:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-different-fields-in-different-events-to-each-other/m-p/123318#M33298</guid>
      <dc:creator>wpreston</dc:creator>
      <dc:date>2014-09-16T18:50:38Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing different fields in different events to each other</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-different-fields-in-different-events-to-each-other/m-p/123319#M33299</link>
      <description>&lt;P&gt;Excellent, glad you found that!  Happy Splunking!&lt;/P&gt;</description>
      <pubDate>Tue, 16 Sep 2014 18:58:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-different-fields-in-different-events-to-each-other/m-p/123319#M33299</guid>
      <dc:creator>wpreston</dc:creator>
      <dc:date>2014-09-16T18:58:43Z</dc:date>
    </item>
  </channel>
</rss>

