Splunk Search

How to correlate similar field values together and adding totals?

jacobfrasca
New Member

I am trying to use a lookup we use to track usage of exceptions in one of our platforms so that we can remove unneeded exceptions as needed. In my search, I am bringing my log data in that would represent usage and taking the domain out of the email address to compare against the values in my lookup. the issue I am running into is that my log will show a domain of "test.example.com" but the exception that would be used is "*.example.com". I am looking for an elegant way to add the usage of "test.example.com" to the counter for "*.example.com". 

My lookup has headers of OBJECT, CATEGORY, USAGE. OBJECT being where the domain would go. Once I get these counters sorted I would write back to the lookup table with the new value for USAGE. 

 

Including the part of my search I am struggling with:

| eval domain=replace(emailAddress,".*?@","")
| stats count(domain) as USAGE by domain
| eval CATEGORY="domain"
| rename domain as OBJECT
| table OBJECT,CATEGORY,USAGE
| append [| inputlookup exceptions.csv]
| stats sum(USAGE) AS USAGE by OBJECT, CATEGORY

Any help is appreciated!  

 

Labels (5)
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

If you set up your lookup with an extra field, called MATCH, which holds the wildcarded domain and OBJECT holds the shorter domain (that you want to group by),e.g.

OBJECTMATCHCATEGORYUSAGE
example.com*.example.comdomain1000

and set up the lookup definition for WILDCARD(MATCH), you can then do something like this

| eval domain=replace(emailAddress,".*?@","")
| stats count(domain) as USAGE by domain
| eval CATEGORY="domain"
| table domain,CATEGORY,USAGE
| lookup exceptions.csv MATCH as domain CATEGORY OUTPUT USAGE as usageFromLookup
| stats sum(USAGE) AS USAGE values(usageFromLookup) as usageFromLookup by OBJECT, CATEGORY
0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...