This statement | stats values(index) as index by InstanceId should certainly give you a field called index which will contain main/other or both Doing | stats values(*) as * dc(index) as i...
See more...
This statement | stats values(index) as index by InstanceId should certainly give you a field called index which will contain main/other or both Doing | stats values(*) as * dc(index) as index_count by InstanceId would give you all the values of every field from both indexes and a field called index_count that would contain a 1 or 2 You can't match the resource id against the instanceid as the events are not yet "joined" together, so there will either be a ResourceId (from index=main) OR an InstanceId (from index=other), so the coalesce+stats will join the two datasets together on that now common field (due to coalesce). Effectively what you are saying is that after the stats, it will show, for each InstanceId (where InstanceId has come from ResourceId in index=main), the values of the indexes those IDs were found in. After the stats you can then match as needed, so I believe what you are trying to do is to then say "I need to only show results, where a ResourceId from index=main has also been found as InstanceId from index=other. So, the logic to decide that is mvcount(index)=2 (this means it was in both indexes). You could use index_count from the dc(index) example above = that is the same as doing the mvcount. Doing values(*) as * is simply a way to carry through all fields combined from both indexes when joining the data together - as you have tried the stats values(index) as index... that should simply carry forward the main+other to that field. Can you given an example of the data you have in both and a search result that highlights what you are getting.