<?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 Compare if an event in different sourcetypes has the same values for a combination of fields in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Compare-if-an-event-in-different-sourcetypes-has-the-same-values/m-p/148333#M41494</link>
    <description>&lt;P&gt;Hey Splunkers, &lt;/P&gt;

&lt;P&gt;We want to track an email communication which is done over multiple servers with multiple log formats. &lt;BR /&gt;
We have three fields that must have the same value in an event in both sourcetypes, if this is true we want to mark the email as accepted.&lt;/P&gt;

&lt;P&gt;The field combination that must match are from, to, subject&lt;/P&gt;

&lt;P&gt;here is an example:&lt;/P&gt;

&lt;P&gt;the log event from the anti spam gateway:&lt;BR /&gt;
&lt;EM&gt;Oct  1 10:08:05 10.1.8.75 date=2014-10-01 time=10:08:05 device_id=FEVM020000026428 log_id=0200014307 type=statistics pri=information session_id="s91884r7014306-s91884r8014306" client_name="xxx.mail.de  [5.123.123.123]" dst_ip="10.1.8.75" **from=&lt;A href="mailto:bla@foo.de" target="_blank"&gt;bla@foo.de&lt;/A&gt; to=&lt;A href="mailto:test@ymca.de" target="_blank"&gt;test@ymca.de&lt;/A&gt;&lt;/EM&gt;* polid="0:1:1" domain="ymca.de" &lt;STRONG&gt;subject="TEST"&lt;/STRONG&gt; mailer="mta" resolved="OK" direction="in" virus="" disposition="Accept" classifier="Not Spam" message_length="1697"*&lt;/P&gt;

&lt;P&gt;the log event from the  receiving mail server: &lt;BR /&gt;
&lt;EM&gt;[2014-10-01 17:20:21.555] [   219316 ms] [Snr- 4169584] [connection13] [INFO ] typ="mail statistic" Snr=4169584 **from=&lt;A href="mailto:bla@foo.de" target="_blank"&gt;bla@foo.de&lt;/A&gt; to=&lt;A href="mailto:test@ymca.de" target="_blank"&gt;test@ymca.de&lt;/A&gt; subject="TEST"&lt;/EM&gt;* disposition=accept direction=in*&lt;/P&gt;

&lt;P&gt;We need a table with the following values:&lt;/P&gt;

&lt;P&gt;from                      to                              subject                AntiSpamOK      MailrcvdOK&lt;BR /&gt;
&lt;A href="mailto:bla@foo.de" target="_blank"&gt;bla@foo.de&lt;/A&gt;          &lt;A href="mailto:test@ymca.de" target="_blank"&gt;test@ymca.de&lt;/A&gt;         TEST                            1                       1&lt;BR /&gt;
&lt;A href="mailto:mail2@test.de" target="_blank"&gt;mail2@test.de&lt;/A&gt;     &lt;A href="mailto:test@ymca.de" target="_blank"&gt;test@ymca.de&lt;/A&gt;         NOT GOOD                1                       0       &lt;/P&gt;

&lt;P&gt;With that we can filter if a mail is processed or not. for example |where   MailrcvdOK=0&lt;/P&gt;

&lt;P&gt;I have tried the following:&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;eventtype="Antispam_Inbound_Mail"  |stats count AS AntiSpamOK by from, to, subject | join type=left from to subject [search eventtype="Mailserver_Inbound_Mail"   |stats count AS MailrcvdOK by from, to, subject ] |eval MailrcvdOK =if(isnull(MailrcvdOK ),0,MailrcvdOK) |fields from to subject AntiSpamOK, MailrcvdOK&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;I have used a left join, because only the mails in the first search must seen definitely on the second one.&lt;BR /&gt;&lt;BR /&gt;
But with this command I don't see any matching row where AntiSpamOK and MailrcvdOK are both 1.&lt;BR /&gt;
I have checked the logs, in both logs are event combination with the same field values. I just don't know how to get it visible. &lt;BR /&gt;
I also tried this with the |set  intersection command without any success. &lt;/P&gt;

&lt;P&gt;Is there a better way to do it? Am I wrong with something?&lt;/P&gt;

&lt;P&gt;Thanks to all&lt;/P&gt;</description>
    <pubDate>Mon, 28 Sep 2020 17:46:21 GMT</pubDate>
    <dc:creator>btiggemann</dc:creator>
    <dc:date>2020-09-28T17:46:21Z</dc:date>
    <item>
      <title>Compare if an event in different sourcetypes has the same values for a combination of fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Compare-if-an-event-in-different-sourcetypes-has-the-same-values/m-p/148333#M41494</link>
      <description>&lt;P&gt;Hey Splunkers, &lt;/P&gt;

&lt;P&gt;We want to track an email communication which is done over multiple servers with multiple log formats. &lt;BR /&gt;
We have three fields that must have the same value in an event in both sourcetypes, if this is true we want to mark the email as accepted.&lt;/P&gt;

&lt;P&gt;The field combination that must match are from, to, subject&lt;/P&gt;

&lt;P&gt;here is an example:&lt;/P&gt;

&lt;P&gt;the log event from the anti spam gateway:&lt;BR /&gt;
&lt;EM&gt;Oct  1 10:08:05 10.1.8.75 date=2014-10-01 time=10:08:05 device_id=FEVM020000026428 log_id=0200014307 type=statistics pri=information session_id="s91884r7014306-s91884r8014306" client_name="xxx.mail.de  [5.123.123.123]" dst_ip="10.1.8.75" **from=&lt;A href="mailto:bla@foo.de" target="_blank"&gt;bla@foo.de&lt;/A&gt; to=&lt;A href="mailto:test@ymca.de" target="_blank"&gt;test@ymca.de&lt;/A&gt;&lt;/EM&gt;* polid="0:1:1" domain="ymca.de" &lt;STRONG&gt;subject="TEST"&lt;/STRONG&gt; mailer="mta" resolved="OK" direction="in" virus="" disposition="Accept" classifier="Not Spam" message_length="1697"*&lt;/P&gt;

&lt;P&gt;the log event from the  receiving mail server: &lt;BR /&gt;
&lt;EM&gt;[2014-10-01 17:20:21.555] [   219316 ms] [Snr- 4169584] [connection13] [INFO ] typ="mail statistic" Snr=4169584 **from=&lt;A href="mailto:bla@foo.de" target="_blank"&gt;bla@foo.de&lt;/A&gt; to=&lt;A href="mailto:test@ymca.de" target="_blank"&gt;test@ymca.de&lt;/A&gt; subject="TEST"&lt;/EM&gt;* disposition=accept direction=in*&lt;/P&gt;

&lt;P&gt;We need a table with the following values:&lt;/P&gt;

&lt;P&gt;from                      to                              subject                AntiSpamOK      MailrcvdOK&lt;BR /&gt;
&lt;A href="mailto:bla@foo.de" target="_blank"&gt;bla@foo.de&lt;/A&gt;          &lt;A href="mailto:test@ymca.de" target="_blank"&gt;test@ymca.de&lt;/A&gt;         TEST                            1                       1&lt;BR /&gt;
&lt;A href="mailto:mail2@test.de" target="_blank"&gt;mail2@test.de&lt;/A&gt;     &lt;A href="mailto:test@ymca.de" target="_blank"&gt;test@ymca.de&lt;/A&gt;         NOT GOOD                1                       0       &lt;/P&gt;

&lt;P&gt;With that we can filter if a mail is processed or not. for example |where   MailrcvdOK=0&lt;/P&gt;

&lt;P&gt;I have tried the following:&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;eventtype="Antispam_Inbound_Mail"  |stats count AS AntiSpamOK by from, to, subject | join type=left from to subject [search eventtype="Mailserver_Inbound_Mail"   |stats count AS MailrcvdOK by from, to, subject ] |eval MailrcvdOK =if(isnull(MailrcvdOK ),0,MailrcvdOK) |fields from to subject AntiSpamOK, MailrcvdOK&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;I have used a left join, because only the mails in the first search must seen definitely on the second one.&lt;BR /&gt;&lt;BR /&gt;
But with this command I don't see any matching row where AntiSpamOK and MailrcvdOK are both 1.&lt;BR /&gt;
I have checked the logs, in both logs are event combination with the same field values. I just don't know how to get it visible. &lt;BR /&gt;
I also tried this with the |set  intersection command without any success. &lt;/P&gt;

&lt;P&gt;Is there a better way to do it? Am I wrong with something?&lt;/P&gt;

&lt;P&gt;Thanks to all&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 17:46:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Compare-if-an-event-in-different-sourcetypes-has-the-same-values/m-p/148333#M41494</guid>
      <dc:creator>btiggemann</dc:creator>
      <dc:date>2020-09-28T17:46:21Z</dc:date>
    </item>
    <item>
      <title>Re: Compare if an event in different sourcetypes has the same values for a combination of fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Compare-if-an-event-in-different-sourcetypes-has-the-same-values/m-p/148334#M41495</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;eventtype="Antispam_Inbound_Mail" OR eventtype="Mailserver_Inbound_Mail"
| stats count(eventtype="Antispam_Inbound_Mail") as AntiSpamOK count(eventtype="Mailserver_Inbound_Mail") as MailrcvdOK
      by from to subject
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This avoids the subsearches, which may be hitting limits and causing the problems. It should also run much faster.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Oct 2014 00:12:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Compare-if-an-event-in-different-sourcetypes-has-the-same-values/m-p/148334#M41495</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2014-10-02T00:12:55Z</dc:date>
    </item>
    <item>
      <title>Re: Compare if an event in different sourcetypes has the same values for a combination of fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Compare-if-an-event-in-different-sourcetypes-has-the-same-values/m-p/148335#M41496</link>
      <description>&lt;P&gt;Hi Lisa, &lt;/P&gt;

&lt;P&gt;it looks like this is it. Thanks for your help and giving a good idea. &lt;/P&gt;

&lt;P&gt;I have adjusted the search to:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;eventtype="AntiSpam_Inbound_Mail" OR eventtype="Mail_Inbound_Mail" | stats count(eval(eventtype="AntiSpam_Inbound_Mail")) as AntiSpamOK count(eval(eventtype="Mail_Inbound_Mail")) as MailrcvdOK by subject |eval Mailfactor=MailrcvdOK-AntiSpamOK
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I was wondering why MailrcvdOK and AntiSpamOK are always "0". It is because you have to use an eval in the count() function. &lt;/P&gt;

&lt;P&gt;Now we have got another problem: &lt;/P&gt;

&lt;P&gt;Sometimes a mail is processed several times in the log because of a mail loop or queuing error. With that the combination of from to subject can occur 3 time in "AntiSpam_Inbound_Mail" and one time in "Mail_Inbound_Mail". &lt;/P&gt;

&lt;P&gt;For example: &lt;/P&gt;

&lt;P&gt;from             to                      subject         AntiSpamOK MailrcvdOK&lt;BR /&gt;
&lt;A href="mailto:bla@foo.de" target="_blank"&gt;bla@foo.de&lt;/A&gt; &lt;A href="mailto:test@ymca.de" target="_blank"&gt;test@ymca.de&lt;/A&gt; TEST             3                        1&lt;BR /&gt;
&lt;A href="mailto:bla1@foo.de" target="_blank"&gt;bla1@foo.de&lt;/A&gt; &lt;A href="mailto:tes1t@ymca.de" target="_blank"&gt;tes1t@ymca.de&lt;/A&gt; TEST        7                        1&lt;/P&gt;

&lt;P&gt;With your search we are not able to see that reprocessed mails. &lt;BR /&gt;
Is there a chance to track this, too?&lt;/P&gt;

&lt;P&gt;Thanks for your help again. &lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 17:47:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Compare-if-an-event-in-different-sourcetypes-has-the-same-values/m-p/148335#M41496</guid>
      <dc:creator>btiggemann</dc:creator>
      <dc:date>2020-09-28T17:47:22Z</dc:date>
    </item>
    <item>
      <title>Re: Compare if an event in different sourcetypes has the same values for a combination of fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Compare-if-an-event-in-different-sourcetypes-has-the-same-values/m-p/148336#M41497</link>
      <description>&lt;P&gt;We fixed it using eventstats instead of stats... At the end it was very easy...&lt;/P&gt;</description>
      <pubDate>Wed, 08 Oct 2014 23:41:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Compare-if-an-event-in-different-sourcetypes-has-the-same-values/m-p/148336#M41497</guid>
      <dc:creator>btiggemann</dc:creator>
      <dc:date>2014-10-08T23:41:41Z</dc:date>
    </item>
  </channel>
</rss>

