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
Get Updates on the Splunk Community!

Data Management Digest – December 2025

Welcome to the December edition of Data Management Digest! As we continue our journey of data innovation, the ...

Index This | What is broken 80% of the time by February?

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

Unlock Faster Time-to-Value on Edge and Ingest Processor with New SPL2 Pipeline ...

Hello Splunk Community,   We're thrilled to share an exciting update that will help you manage your data more ...