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!

Mastering Threat Intelligence in ES 8.5, Splunk AI Assistant v2, and More from Splunk ...

Splunk Lantern is Splunk’s customer success center that provides practical guidance from Splunk experts on key ...

Break the Build: Inside the KubeDoom Lounge at .conf26

    You step up to the machine. The pixelated corridors of a certain 1993 FPS load in front of you, EMP Pulse ...

Splunk Auto Ingestion Parallel Pipeline Scaling

Why this feature matters Many Splunk environments experience ingestion pressure long before the host is fully ...