Splunk Search

Get distinct count from different sources

raghubankapur
Engager

I have 3 different sources of the same filed. I want to aggregate all the 3 sources and get the distinct count of the field

eg.

sourcetype=source1 | stats dc(userlist)

sourcetype=source2 | stats dc(line.userlist)

sourcetype=source3 | stats dc(line.subject)

 

Here userlist, line.userlist, line.subject are all the same attributes but being logged differently. Now I want to get the dc of userlist+line.userlist+line.subject. Any help is appreciated.

Labels (2)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

Assuming that the fields only exist in their respective sourcetypes, you could try something like this

sourcetype=source1 OR sourcetype=source2 OR sourcetype=source3
| eval userlist=coalesce(userlist, line.userlist, line.subject)
| stats dc(userlist)

View solution in original post

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Assuming that the fields only exist in their respective sourcetypes, you could try something like this

sourcetype=source1 OR sourcetype=source2 OR sourcetype=source3
| eval userlist=coalesce(userlist, line.userlist, line.subject)
| stats dc(userlist)
0 Karma

raghubankapur
Engager

This works well @ITWhisperer 

0 Karma
Get Updates on the Splunk Community!

What You Read The Most: Splunk Lantern’s Most Popular Articles!

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

See your relevant APM services, dashboards, and alerts in one place with the updated ...

As a Splunk Observability user, you have a lot of data you have to manage, prioritize, and troubleshoot on a ...

Index This | What goes away as soon as you talk about it?

May 2025 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with this month’s ...