I have a multiple events in a log file which contains field A and field B but not in all the events, I need to compare the field B with field A, If field B does not exist in any of the events then I need to list out the field B values.
That last sentence does not seem to make sense. Maybe the last B should be A? Sample events and output mockup for both scenarios will help us help you.
Can you give sample logs? Or explain with sample values?