<?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: Search and compare data within 3 fields to find positive and negative matches in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Search-and-compare-data-within-3-fields-to-find-positive-and/m-p/511642#M143446</link>
    <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/224351"&gt;@Glioblaster&lt;/a&gt;&amp;nbsp;As well as using match, as suggested by&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/184221"&gt;@to4kawa&lt;/a&gt;&amp;nbsp;you can always extract the email address using the rex statement, as in this example. Note that it still uses match() to do the compare.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval Message="{\"message\":{\"hdr\":{\"to\":\"Smith, Joe &amp;lt;joe.smith@email.com&amp;gt;\",\"cc\":\"Smith, Fred &amp;lt;fred.smith@email.com&amp;gt;\"}},\"orig_recipient\":\"joe.smith@email.com\""
| spath input=Message
| rex field=message.hdr.cc "&amp;lt;(?&amp;lt;email_cc&amp;gt;[^&amp;gt;]*)"
| rex field=message.hdr.to "&amp;lt;(?&amp;lt;email_to&amp;gt;[^&amp;gt;]*)"
| eval to_is_orig=if(match(orig_recipient,email_to),"EQUAL","NOT_EQUAL")&lt;/LI-CODE&gt;&lt;P&gt;Hope this is useful.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 29 Jul 2020 22:00:27 GMT</pubDate>
    <dc:creator>bowesmana</dc:creator>
    <dc:date>2020-07-29T22:00:27Z</dc:date>
    <item>
      <title>Search and compare data within 3 fields to find positive and negative matches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-and-compare-data-within-3-fields-to-find-positive-and/m-p/511632#M143439</link>
      <description>&lt;P&gt;I have a search yielding data from three different email fields, call them msg.header.to{}, msg.header.cc{} and orig_recipient.&amp;nbsp; I am looking to see if the email address contained within orig_recipient matches either of the other two.&amp;nbsp; The issue is that Splunk captures the data differently in the msg.header columns.&lt;/P&gt;&lt;P&gt;For example, the msg.header columns output is "Smith, Joe &amp;lt;joe.smith@email.com&amp;gt;", while the output in the orig_recipient would only be "joe.smith@email.com".&amp;nbsp; &amp;nbsp;So, when I ask Splunk to tell me if the orig_recipient email address is in the msg.header.to{}, I get a negative.&amp;nbsp; I have tried Like, If, Where and others, along with using wildcards but maybe my syntax is wrong.&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am looking to see how I can search within a field using the value of another field as the search parameter.&amp;nbsp; Also, if that is not possible, extracting the data between the &amp;lt;&amp;gt; and putting it into another field to compare off of that field might work.&lt;/P&gt;&lt;P&gt;Thank you for your time and attention to this matter.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jul 2020 21:10:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-and-compare-data-within-3-fields-to-find-positive-and/m-p/511632#M143439</guid>
      <dc:creator>Glioblaster</dc:creator>
      <dc:date>2020-07-29T21:10:10Z</dc:date>
    </item>
    <item>
      <title>Re: Search and compare data within 3 fields to find positive and negative matches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-and-compare-data-within-3-fields-to-find-positive-and/m-p/511637#M143443</link>
      <description>&lt;P&gt;&lt;SPAN&gt;|eval check=if(match('msg.header.to{}',&amp;nbsp;orig_recipient), 1,0)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;How about &lt;STRONG&gt;match&lt;/STRONG&gt;()?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jul 2020 21:48:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-and-compare-data-within-3-fields-to-find-positive-and/m-p/511637#M143443</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-07-29T21:48:10Z</dc:date>
    </item>
    <item>
      <title>Re: Search and compare data within 3 fields to find positive and negative matches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-and-compare-data-within-3-fields-to-find-positive-and/m-p/511642#M143446</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/224351"&gt;@Glioblaster&lt;/a&gt;&amp;nbsp;As well as using match, as suggested by&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/184221"&gt;@to4kawa&lt;/a&gt;&amp;nbsp;you can always extract the email address using the rex statement, as in this example. Note that it still uses match() to do the compare.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval Message="{\"message\":{\"hdr\":{\"to\":\"Smith, Joe &amp;lt;joe.smith@email.com&amp;gt;\",\"cc\":\"Smith, Fred &amp;lt;fred.smith@email.com&amp;gt;\"}},\"orig_recipient\":\"joe.smith@email.com\""
| spath input=Message
| rex field=message.hdr.cc "&amp;lt;(?&amp;lt;email_cc&amp;gt;[^&amp;gt;]*)"
| rex field=message.hdr.to "&amp;lt;(?&amp;lt;email_to&amp;gt;[^&amp;gt;]*)"
| eval to_is_orig=if(match(orig_recipient,email_to),"EQUAL","NOT_EQUAL")&lt;/LI-CODE&gt;&lt;P&gt;Hope this is useful.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jul 2020 22:00:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-and-compare-data-within-3-fields-to-find-positive-and/m-p/511642#M143446</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2020-07-29T22:00:27Z</dc:date>
    </item>
    <item>
      <title>Re: Search and compare data within 3 fields to find positive and negative matches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-and-compare-data-within-3-fields-to-find-positive-and/m-p/511734#M143485</link>
      <description>&lt;P&gt;Thank you but the result was all negative as it was the same problem I am running into where Splunk does not look within the field to match the results so the email addresses inside the &amp;lt;&amp;gt; are not being parsed against the email addresses in orig_recipient.&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jul 2020 11:00:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-and-compare-data-within-3-fields-to-find-positive-and/m-p/511734#M143485</guid>
      <dc:creator>Glioblaster</dc:creator>
      <dc:date>2020-07-30T11:00:17Z</dc:date>
    </item>
    <item>
      <title>Re: Search and compare data within 3 fields to find positive and negative matches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-and-compare-data-within-3-fields-to-find-positive-and/m-p/511739#M143487</link>
      <description>&lt;P&gt;Thank you. I tried this but it did not like my following syntax (received "Error in 'eval' command. The expression is malformed.") as I need to search against the fields, I substituted the field names where you put the email addresses.&amp;nbsp; I wrote the following:&lt;/P&gt;&lt;P&gt;eval Message="{\"message\":{\"hdr"\{\"to"\:\"'msg.header.to{}'\",\"cc\":\"'msg.header.cc{}'\"}},\"orig_recipient\""&lt;/P&gt;&lt;P&gt;All else was the same from your reply.&amp;nbsp; In addition, I will be putting an OR command as I need to search against the .to and .cc fields.&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jul 2020 11:33:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-and-compare-data-within-3-fields-to-find-positive-and/m-p/511739#M143487</guid>
      <dc:creator>Glioblaster</dc:creator>
      <dc:date>2020-07-30T11:33:34Z</dc:date>
    </item>
    <item>
      <title>Re: Search and compare data within 3 fields to find positive and negative matches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-and-compare-data-within-3-fields-to-find-positive-and/m-p/511840#M143517</link>
      <description>&lt;P&gt;Update, so as I am continuing to work on this I changed the parameters to this:&lt;/P&gt;&lt;P&gt;rex field=msg.header.to{} "&amp;lt;(?&amp;lt;test&amp;gt;.*)&amp;gt;" and it worked with providing me the email address contained within the "&amp;lt;&amp;gt;".&amp;nbsp; My next issue is to make it work on multiple email addresses within the same field.&amp;nbsp; Suggestions are welcomed.&amp;nbsp; After I get the email addresses extracted out into a new field, I can then write comparison expressions against my orig_recipient field.&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jul 2020 19:24:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-and-compare-data-within-3-fields-to-find-positive-and/m-p/511840#M143517</guid>
      <dc:creator>Glioblaster</dc:creator>
      <dc:date>2020-07-30T19:24:37Z</dc:date>
    </item>
    <item>
      <title>Re: Search and compare data within 3 fields to find positive and negative matches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-and-compare-data-within-3-fields-to-find-positive-and/m-p/511857#M143525</link>
      <description>&lt;P&gt;Solved:&lt;/P&gt;&lt;P&gt;This is what worked for my search and I also had some mixed case letters so I added the case "lower".&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;| rex field=msg.header.to{}&amp;nbsp; max_match=0 "&amp;lt;(?&amp;lt;test&amp;gt;.*)&amp;gt;"&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;|&amp;nbsp;rex field=msg.header.cc{}&amp;nbsp; max_match=0 "&amp;lt;(?&amp;lt;test2&amp;gt;.*)&amp;gt;"&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;| eval test=lower(test)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;| eval test=lower(test2)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;| eval test3=if(orig_recipient=test OR orig_recipient=test2), "TRUE", "FALSE")&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jul 2020 20:30:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-and-compare-data-within-3-fields-to-find-positive-and/m-p/511857#M143525</guid>
      <dc:creator>Glioblaster</dc:creator>
      <dc:date>2020-07-30T20:30:24Z</dc:date>
    </item>
  </channel>
</rss>

