I want to give my model a glare effect at robots eye,
so I gave the material assigned to the eye Pass Index of 1
then when I went to compositor and made this node set up,
in the viewer I could not see anything like that, (BW Image)
This is pretty weird. I can think of three possible workarouds:
Your setup seems to be correct.
The material you want to use as mask must have an Pass Index number.
In the render layers enable Material Index
Now press F12: YOU HAVE TO RENDER THE IMAGE for this changes to update, and the compositor has the proper information to work with (Sounds simple, but this step is sometimes overlooked).
After that, the node setup could be something like this, where the ID mask index matches the index set for the eye material and is used as a mask for further transformations: