Grok condition for two different type of files

Suppose I have two log types in a log file..whenever I encounter the error pattern logs, an ID is generated in some other directory with a file having the error id which caused the error in those logs.
Now I want to extract those generated IDs which may have a specific pattern and index them into elastic.

Is this possible?