Splunk Search

Unable to get the matching files using join command.

chinmay25
Path Finder

We used the inner join command to get the matching files. However, the same command does not work with the current format of the events. Hence we extracted (rex) the data. Here is the current search that is not working. I would appreciate it if we could get alternatives to this. The total number of files is 2605. 7 files do not match and 2598 files match. We need the search to work for the matching files.

index=xyz source = FILE sourcetype = syncsort:file  JOBNAME="xyz-B" | rex field=_raw "\S{45}\s\S{11}\s\S{45}\s*\S{92}(?[A-Z0-9].*)"
| join type=inner DATA [ search index=xyz source = FILE sourcetype = syncsort:file  JOBNAME="xyz-R" | rex field=_raw "\S{45}\s\S{11}\s\S{45}\s*\S{92}(?[A-Z0-9].*)"
    | fields DATA] 
| stats count as COUNT by DATA
| addcoltotals labelfield=DATA label="Total"
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

Try not using join. The stats command will combine events that have a common field value when you use the by clause.

index=xyz source = FILE sourcetype = syncsort:file (JOBNAME="xyz-B"  OR JOBNAME="xyz-R")
| rex field=_raw "\S{45}\s\S{11}\s\S{45}\s*\S{92}(?<DATA>[A-Z0-9].)"
| stats values(*) as * by DATA
| stats count as COUNT by DATA
| addcoltotals labelfield=DATA label="Total"
---
If this reply helps you, Karma would be appreciated.

View solution in original post

0 Karma

richgalloway
SplunkTrust
SplunkTrust

Try not using join. The stats command will combine events that have a common field value when you use the by clause.

index=xyz source = FILE sourcetype = syncsort:file (JOBNAME="xyz-B"  OR JOBNAME="xyz-R")
| rex field=_raw "\S{45}\s\S{11}\s\S{45}\s*\S{92}(?<DATA>[A-Z0-9].)"
| stats values(*) as * by DATA
| stats count as COUNT by DATA
| addcoltotals labelfield=DATA label="Total"
---
If this reply helps you, Karma would be appreciated.
0 Karma

chinmay25
Path Finder

Thanks for the answer. I tried it...however, I am getting duplicates now. Its counting it twice.

0 Karma

richgalloway
SplunkTrust
SplunkTrust

I was afraid that would happen. Try the revised query.

---
If this reply helps you, Karma would be appreciated.
0 Karma

chinmay25
Path Finder

This worked. My other concern is, if this will work if we have two different indexes?

0 Karma

richgalloway
SplunkTrust
SplunkTrust

The method works. Just change index=xyz to (index=xyz OR index=abc).

If your problem is resolved then please accept the answer to help future readers.

---
If this reply helps you, Karma would be appreciated.
0 Karma

chinmay25
Path Finder

Sounds good.
Thanks.

0 Karma
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!

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas     Cisco Live 2026 is almost here, and this ...

What Is the Name of the USB Key Inserted by Bob Smith? (BOTS Hint, Not the Answer)

Hello Splunkers,   So you searched, “what is the name of the usb key inserted by bob smith?”  Not gonna lie… ...

Automating Threat Operations and Threat Hunting with Recorded Future

    Automating Threat Operations and Threat Hunting with Recorded Future June 29, 2026 | Register   Is your ...