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 ( http://answers.splunk.com/questions/1478/sendmail-transactions ).
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:
one email has multiple events
all events include the qid
the recipient address is only extracted once per email
you have extracted the qid, sender and recipient fields
Using:
sourcetype=mail
[search sourcetype=mail
[email protected]
| dedup qid
| fields qid
]
| stats count by recipient
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.
I went ahead and did a test in my environment, comparing
tag=mail
[search tag=ab_mail
[email protected]
| dedup ExchangeMSGID
| fields ExchangeMSGID
]
| stats count by RecipientAddress
to
tag=mail | transaction ExchangeMSGID maxspan=30s
| search
[email protected]
| stats count by RecipientAddress
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...
... View more