Splunk Search

i want to iterate values a field from one source type and compare each values with set of values in another field of different sourcetype

vkrishnachand
New Member

Hi

I have two sourcetype A and B where sourcetype A has field A1 and sourcetype B has field B1.

My base query is something like index=test (sourcetype= A OR sourcetype=B)

A1 which belongs to sourcetype A has below values.

1,4,5,7,8,9

B1 which belogs to sourcetype B has below values

11,12,4,56,7,10

All i want to do is iterate field A1 and start comparing it with each values in B1 and see which two values are equal and record the corresponding events in A1 using eval statement with separate field Hit and have the value as matching OR not matching

the comparison is something like 1 with 11 , 1 with 12 , 1 with 4 , 1 with 56 , 1 with 7 and 1 with 10. The next comparision is like 4 with 11 , 4 with 12 , 4 with 4 now this is a hit so i record HIT value for this event in source type A1 under seperate field.

I did a logic with transaction command along with coalesce , but it does not suit my requirement due to some factors . I want to do it in some other way. kindly assist.

0 Karma

renjith_nair
Legend

@vkrishnachand,

From your requirement, you have a common field in both sourcetypes and want to get the events from sourcetype A if there is a matching value in sourcetype B. Assuming the field name as ID

try with stats and lets know what's missing

 index=test (sourcetype=A OR sourcetype=B)
 |stats values(sourcetypeA_filed1 ) as sourcetypeA_filed1 , ............
        values(sourcetypeA_filedn ) as sourcetypeA_filedn ,dc(sourcetype) as c by ID|where c>1
Happy Splunking!
0 Karma
Get Updates on the Splunk Community!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...