<?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 query to display some sendmail details in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Search-query-to-display-some-sendmail-details/m-p/63114#M15590</link>
    <description>&lt;P&gt;I would do this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=sendmail | stats values(from) as from,values(to) as tolist by qid | mvexpand tolist | rename tolist as to| stats count by from,to
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;It's basically the same as &lt;CODE&gt;transaction&lt;/CODE&gt;, but if you're running with more than one indexer, it will scale up much better. That's because &lt;CODE&gt;transaction&lt;/CODE&gt; does a lot of work that we don't need here, that prevents the job to be more effectively distributed by map-reduce (e.g., keeping timestamps in order, calculating durations). The &lt;CODE&gt;stats&lt;/CODE&gt; command above doesn't do this as much, so should run much faster than &lt;CODE&gt;transaction&lt;/CODE&gt; if you have multiple indexers.&lt;/P&gt;</description>
    <pubDate>Mon, 21 Mar 2011 00:36:39 GMT</pubDate>
    <dc:creator>gkanapathy</dc:creator>
    <dc:date>2011-03-21T00:36:39Z</dc:date>
    <item>
      <title>Search query to display some sendmail details</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-query-to-display-some-sendmail-details/m-p/63111#M15587</link>
      <description>&lt;P&gt;I'd like to come up with a search/report that can display the number of emails sent "from" a particular to unique "to" addresses over a period of time. The output come look something like:&lt;/P&gt;

&lt;PRE&gt;
user@domain1.com   15
somebody@another.com  35
test@someplace.com  50
Total Sent 100
&lt;/PRE&gt;

&lt;P&gt;So here is what I'm trying to figure out:&lt;/P&gt;

&lt;P&gt;Find all results for "mysender@mydomain.com". 
Take the qid (example: p2IIboft020468) and do a subsearch to find the "to" address
Format the results from the "to" search into the above format.&lt;/P&gt;</description>
      <pubDate>Sat, 19 Mar 2011 01:40:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-query-to-display-some-sendmail-details/m-p/63111#M15587</guid>
      <dc:creator>jeffwarn</dc:creator>
      <dc:date>2011-03-19T01:40:22Z</dc:date>
    </item>
    <item>
      <title>Re: Search query to display some sendmail details</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-query-to-display-some-sendmail-details/m-p/63112#M15588</link>
      <description>&lt;P&gt;My take on this: first, create the needed field extractions for the logs. Let's call the sourcetype "sendmail" and the fields of primary interest "qid", "from" and "to". Now with these extractions defined, group events together with a &lt;CODE&gt;transaction&lt;/CODE&gt; based on &lt;CODE&gt;qid&lt;/CODE&gt;. Then simply make a toplist using &lt;CODE&gt;top&lt;/CODE&gt;, say for 100 entries.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="sendmail" | transaction qid | top 100 from,to
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;That should give you something similar to what you seem to be looking for. The only thing missing would be the total count at the end, which you'll have to handle separately.&lt;/P&gt;</description>
      <pubDate>Sat, 19 Mar 2011 04:43:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-query-to-display-some-sendmail-details/m-p/63112#M15588</guid>
      <dc:creator>Ayn</dc:creator>
      <dc:date>2011-03-19T04:43:53Z</dc:date>
    </item>
    <item>
      <title>Re: Search query to display some sendmail details</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-query-to-display-some-sendmail-details/m-p/63113#M15589</link>
      <description>&lt;P&gt;I've been using Ayn's method, myself, for some time, but transaction is painfully slow over a large log. In looking at this particular question, I actually found a vastly better method, courtesy of gkanapathy ( &lt;A href="http://answers.splunk.com/questions/1478/sendmail-transactions" rel="nofollow"&gt;http://answers.splunk.com/questions/1478/sendmail-transactions&lt;/A&gt; ).&lt;/P&gt;

&lt;P&gt;If you're looking for data about a particular from address, it's much faster to filter on those qids first and then look specifically at the To addresses, if the below assumptions are correct:&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;one email has multiple events&lt;/LI&gt;
&lt;LI&gt;all events include the qid&lt;/LI&gt;
&lt;LI&gt;the recipient address is only extracted once per email&lt;/LI&gt;
&lt;LI&gt;you have extracted the qid, sender and recipient fields&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;Using:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=mail 
   [search sourcetype=mail sender=myuser@mycompany.com 
       | dedup qid 
       | fields qid
   ] 
   | stats count by recipient
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I'm not sure how to do a totals row in the same table.. If you're going to put this in a dashboard, though, you could do the above (sans the stats command) as a hidden search, have one post process for the main table, and then another post process for a single value field with the total number of emails sent.&lt;/P&gt;

&lt;P&gt;I went ahead and did a test in my environment, comparing &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;tag=mail 
   [search tag=ab_mail SenderAddress=me@me.com 
         | dedup ExchangeMSGID 
         | fields ExchangeMSGID
   ] 
   | stats count by RecipientAddress 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;to &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;tag=mail | transaction ExchangeMSGID maxspan=30s 
            | search SenderAddress=me@me.com 
            | stats count by RecipientAddress
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;over the last 30 days. The first one completed in 38 seconds; I killed the second one 4.8% in, after 227 seconds. Now I need to go re-write some of my own reports to use this better method...&lt;/P&gt;</description>
      <pubDate>Sat, 19 Mar 2011 07:18:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-query-to-display-some-sendmail-details/m-p/63113#M15589</guid>
      <dc:creator>David</dc:creator>
      <dc:date>2011-03-19T07:18:25Z</dc:date>
    </item>
    <item>
      <title>Re: Search query to display some sendmail details</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-query-to-display-some-sendmail-details/m-p/63114#M15590</link>
      <description>&lt;P&gt;I would do this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=sendmail | stats values(from) as from,values(to) as tolist by qid | mvexpand tolist | rename tolist as to| stats count by from,to
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;It's basically the same as &lt;CODE&gt;transaction&lt;/CODE&gt;, but if you're running with more than one indexer, it will scale up much better. That's because &lt;CODE&gt;transaction&lt;/CODE&gt; does a lot of work that we don't need here, that prevents the job to be more effectively distributed by map-reduce (e.g., keeping timestamps in order, calculating durations). The &lt;CODE&gt;stats&lt;/CODE&gt; command above doesn't do this as much, so should run much faster than &lt;CODE&gt;transaction&lt;/CODE&gt; if you have multiple indexers.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Mar 2011 00:36:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-query-to-display-some-sendmail-details/m-p/63114#M15590</guid>
      <dc:creator>gkanapathy</dc:creator>
      <dc:date>2011-03-21T00:36:39Z</dc:date>
    </item>
    <item>
      <title>Re: Search query to display some sendmail details</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-query-to-display-some-sendmail-details/m-p/63115#M15591</link>
      <description>&lt;P&gt;Thanks. I did notice that using transaction would really chock the system pretty good. I had come up with something that was somewhat useful, but after seeing the responses in this thread, I still have a lot to learn!&lt;/P&gt;</description>
      <pubDate>Tue, 22 Mar 2011 22:19:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-query-to-display-some-sendmail-details/m-p/63115#M15591</guid>
      <dc:creator>jeffwarn</dc:creator>
      <dc:date>2011-03-22T22:19:28Z</dc:date>
    </item>
  </channel>
</rss>

