I read that he made a modified version of Otto von Guericke's electrostatic generator but I want to know how he came to know that mercury can glow light in his generator at that time?
The glow of mercury in a vacuum is known as the barometric light. It was discovered at the end of 1675 by Picard, a French astronomer (he was using barometric measurements to correct for refraction in his observations of stars):
"Towards the year 1676, Monsieur Picard was transporting his barometer from the Observatory to Port Saint Michel during the night, [when] he noticed a light in a part of the tube where the mercury was moving; this phenomenon having surprised him, he immediately reported it to the sçavans..." ["Sur la lumière du baromètre" [On the light of the barometer], Histoire de l'Académie Royale des sciences de Paris,vol. 2, pages 202-203 (1694)]
Johann Bernoulli demonstrated the phenomenon to the French Academy in 1700, where Hauksbee learned of it, and experimented with it extensively. He was also the first to use a glass ball in an electrostatic generator, so the idea of combining the effects was natural. In 1705 he discovered that if he created vacuum inside, rubbed the ball, and put his hand on it, the mercury glowed quite brightly. In 1706 he invented an "influence machine" that demonstrated the effect. Later it was used in gas-discharge lamps, neon lights, and mercury vapor lamps, see Hauksbee's scientific contributions that references Burke's Connections book, p.75.