Splunk Search

Count a value by a value without stats?

brienhawker
Explorer

Im currently trying to build a search where im trying to determine if a user is trying to send data out maliciously. One of the things that i am trying to do is count the number of recipients by the number of senders before the stats line so that I can use that data in an eval giving me a threat number between 1 and 5

index=msexchange size>2000000 directionality="Originating" AND action="delivered" AND recipient!="iccu.com" AND NOT
(message_subject="RE
" OR message_subject="FW*" OR message_subject="EXTERNAL") AND
(recipient="gmail.com" OR recipient=".edu" OR recipient="hotmail.com" OR recipient "*yahoo.com" OR recipient="*msn.com" OR
recipient="*outlook.com" OR recipient="*aol.com" OR recipient="*zoho.com" OR recipient="*icloud.com" OR recipient="*inbox.com" OR recipient="*mail.com" OR recipient="*yandex.com" OR recipient="*protonmail.com")
|eval threat_num=5
**somewhere in here i am needing to count the recipients by the senders so that i can do an eval to determine the value of diff
*
|eval appraise=if(like(message_subject, "%ppraisal%"), 2, 0)
|eval payment=if(like(message_subject, "%ayment%"), 2, 0)
|eval loan=if(like(message_subject, "%oan%"), 2, 0)
|eval diff=(threat_num - appraise - payment - loan)
|stats values(size) as "Message Size" list(diff) values(message_subject) values(title) values(recipient) as Recipient by sender | sort -"Message Size"

Ive looked into using mvcount but it doesnt appear that you can use a 'by' value in it. Anything helps.
Thanks!

0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

@brienhawker

Have you tried eventstats?

https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/eventstats

Eg.

Number of recipients by the number of senders

YOUR_SEARCH |eventstats dc(recipient) as NumberOfRecipient by sender 
0 Karma
Get Updates on the Splunk Community!

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...