Splunk Search

Join between indexes and sum fields

giulio
Engager

Hi all, I have two indexes with the following fields:

index=sofware
sw                        version       author
software_1            1.0           Mark
software_2            1.1           Holly
software_3            1.2           Tom
software_4            1.3          Gorge


index=downloads
timestamp                                         sw
2021-11-23 00:00:00          software_1
2021-11-22 00:00:00          software_1
2021-11-21 00:00:00          software_4
2021-11-20 00:00:00          software_1
2021-11-19 00:00:00          software_3
2021-11-18 00:00:00          software_1

I need to create a report with the number of downloads for each software, something like this:

sw                     version                 author               #downloads
software_1       1.0                     Mark                               4
software_2       1.1                     Holly                               0
software_3       1.2                     Tom                                1
software_4       1.3                   Gorge                               1

I tried using left join but couldn't fine any good solution.
Thanks for helping.

Labels (3)
0 Karma
1 Solution

giulio
Engager

thanks all for your suggestions.

finally used this:

index="software"
| table sw version author
| join type=left sw [search index="downloads" | stats count by sw | table sw, count
| rename count as #downloads]
| fillnull value=0 #downloads

View solution in original post

0 Karma

giulio
Engager

thanks all for your suggestions.

finally used this:

index="software"
| table sw version author
| join type=left sw [search index="downloads" | stats count by sw | table sw, count
| rename count as #downloads]
| fillnull value=0 #downloads

0 Karma

richgalloway
SplunkTrust
SplunkTrust

We might be able to fix the join you tried if you showed us the query and what didn't work about it.

As the manual says, however, join usually is not the best solution because it doesn't perform well.  Try using append, instead.

index=sofware
| append [ search index=downloads ]
| stats count by sw version author
---
If this reply helps you, Karma would be appreciated.
0 Karma

PickleRick
SplunkTrust
SplunkTrust

We might even spare ourselves the append and do a simple alternative.

And I'm not sure if it shouldn't be aggregatted slightly differently.

index=software OR index=downloads
| stats count(timestamp) as downloads values(version) as version
values(author) as author by sw

But I'm not sure if your or mine aggregation is better because we simply don't see the full raw data.

Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...

Modernize your Splunk Apps – Introducing Python 3.13 in Splunk

We are excited to announce that the upcoming releases of Splunk Enterprise 10.2.x and Splunk Cloud Platform ...

Step into “Hunt the Insider: An Splunk ES Premier Mystery” to catch a cybercriminal ...

After a whole week of being on call, you fell asleep on your keyboard, and you hit a sequence of buttons that ...