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

New Member


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.


B1 which belogs to sourcetype B has below values


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



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
0 Karma
Did you miss .conf21 Virtual?

Good news! The event's keynotes and many of its breakout sessions are now available online, and still totally FREE!