Splunk Search

Getting top values from two fields

kennethp
Engager

I have a index that contains both destination and source countries in each entry.
I would like to get a list over top 10 countries, regardless of the source or destination.

I have tried something like this:

... | top limit=10 srccountry,dstcountry

But this doesnt work, since it shows top based on both source and destination.

Something like this I was hoping would work, but clearly doesnt

... | top limit=10 srccountry OR dstcountry

I was thinking that I could add the results from two searches and addning them, but not sure how to do this.

Does anybody knows how to solve this? (if possible)

Tags (4)
1 Solution

martin_mueller
SplunkTrust
SplunkTrust

You could do something like this:

your search | eval country = srccountry . ";" . dstcountry | makemv delim=";" country | mvexpand country | top country

That will make two events for each event, one with country=srccountry and one with country=dstcountry, and then count the top ten countries.

View solution in original post

martin_mueller
SplunkTrust
SplunkTrust

You could do something like this:

your search | eval country = srccountry . ";" . dstcountry | makemv delim=";" country | mvexpand country | top country

That will make two events for each event, one with country=srccountry and one with country=dstcountry, and then count the top ten countries.

Get Updates on the Splunk Community!

Webinar Recap | Revolutionizing IT Operations: The Transformative Power of AI and ML ...

The Transformative Power of AI and ML in Enhancing Observability   In the realm of IT operations, the ...

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...