<?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 Using regex to extract domain from delimited email recipients, and then count them in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Using-regex-to-extract-domain-from-delimited-email-recipients/m-p/66249#M16444</link>
    <description>&lt;P&gt;I need to count the number of incoming emails from external and internal sources, and the number going out to internal and external sources. &lt;/P&gt;

&lt;P&gt;My data has sender_address and recipient_address fields. They look like: "email1@domain.com;email2@domain2.com"&lt;/P&gt;

&lt;P&gt;I have used regex to extract the domain but I am having trouble extracting the domain for additional email addresses when specified (delimited by &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt; &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=hubtracking | rex field=sender_address ".[^@]+?@(?&amp;lt;sender_domain&amp;gt;.+)" | rex field=recipient_address ".[^@]+?@(?&amp;lt;recipient_domain&amp;gt;.+)" | stats count as TotalMessages, count(eval(sender_domain="mydomain.ca" AND recipient_domain="mydomain.ca")) as FromInternal, (eval(sender_domain!="mydomain.ca" AND recipient_domain="mydomain.ca")) as FromExternal
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This kind of works...but the problem is that I'm only counting the first address specified in that field. I imagine that I first need to extract only the domain names, and then count them?&lt;/P&gt;</description>
    <pubDate>Thu, 24 Mar 2011 00:30:33 GMT</pubDate>
    <dc:creator>jamesklassen</dc:creator>
    <dc:date>2011-03-24T00:30:33Z</dc:date>
    <item>
      <title>Using regex to extract domain from delimited email recipients, and then count them</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Using-regex-to-extract-domain-from-delimited-email-recipients/m-p/66249#M16444</link>
      <description>&lt;P&gt;I need to count the number of incoming emails from external and internal sources, and the number going out to internal and external sources. &lt;/P&gt;

&lt;P&gt;My data has sender_address and recipient_address fields. They look like: "email1@domain.com;email2@domain2.com"&lt;/P&gt;

&lt;P&gt;I have used regex to extract the domain but I am having trouble extracting the domain for additional email addresses when specified (delimited by &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt; &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=hubtracking | rex field=sender_address ".[^@]+?@(?&amp;lt;sender_domain&amp;gt;.+)" | rex field=recipient_address ".[^@]+?@(?&amp;lt;recipient_domain&amp;gt;.+)" | stats count as TotalMessages, count(eval(sender_domain="mydomain.ca" AND recipient_domain="mydomain.ca")) as FromInternal, (eval(sender_domain!="mydomain.ca" AND recipient_domain="mydomain.ca")) as FromExternal
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This kind of works...but the problem is that I'm only counting the first address specified in that field. I imagine that I first need to extract only the domain names, and then count them?&lt;/P&gt;</description>
      <pubDate>Thu, 24 Mar 2011 00:30:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Using-regex-to-extract-domain-from-delimited-email-recipients/m-p/66249#M16444</guid>
      <dc:creator>jamesklassen</dc:creator>
      <dc:date>2011-03-24T00:30:33Z</dc:date>
    </item>
    <item>
      <title>Re: Using regex to extract domain from delimited email recipients, and then count them</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Using-regex-to-extract-domain-from-delimited-email-recipients/m-p/66250#M16445</link>
      <description>&lt;P&gt;I have the regex now, I just need to figure out how to count all of the domains now: rex field=sender_address "[a-zA-Z][\w.-]&lt;EM&gt;[a-zA-Z0-9]@(?&lt;SENDER_DOMAIN&gt;[a-zA-Z0-9][\w.-]&lt;/SENDER_DOMAIN&gt;&lt;/EM&gt;[a-zA-Z0-9].[a-zA-Z][a-zA-Z.]*[a-zA-Z])" | where(name = ";")&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 09:26:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Using-regex-to-extract-domain-from-delimited-email-recipients/m-p/66250#M16445</guid>
      <dc:creator>jamesklassen</dc:creator>
      <dc:date>2020-09-28T09:26:36Z</dc:date>
    </item>
    <item>
      <title>Re: Using regex to extract domain from delimited email recipients, and then count them</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Using-regex-to-extract-domain-from-delimited-email-recipients/m-p/66251#M16446</link>
      <description>&lt;P&gt;Got it, here's an example for anyone else working to get stats from Exchange 2010 message tracking logs:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=hubtracking NOT SystemMailbox* | dedup message_id | rex field=sender_address "[a-zA-Z][\w\.-]*[a-zA-Z0-9]@(?&amp;lt;sender_domain&amp;gt;[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z])" | rex field=recipient_address "[a-zA-Z][\w\.-]*[a-zA-Z0-9]@(?&amp;lt;recipient_domain&amp;gt;[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z])" | stats sum(recipient_count) as TotalMessages, count(eval(sender_domain="yourdomain.com" AND recipient_domain="yourdomain.com")) as FromInternal
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 24 Mar 2011 03:54:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Using-regex-to-extract-domain-from-delimited-email-recipients/m-p/66251#M16446</guid>
      <dc:creator>jamesklassen</dc:creator>
      <dc:date>2011-03-24T03:54:23Z</dc:date>
    </item>
  </channel>
</rss>

