Salim bin Abdullah narrates from his father (Sayyiduna Abdullah bin Umar, may Allah be pleased with them both) that whenever the Prophet (peace and blessings be upon him) heard thunder or the crash of thunderbolts, he would say: 'Allahumma la taqtulna bi-ghadabika, wa la tuhlikna bi-'adhabika, wa 'afina qabla dhalik' (O Allah, do not kill us with Your wrath, nor destroy us with Your punishment, and pardon us before they come).
Hadith Referenceالسنن الكبرى للبيهقي / كتاب صلاة الاستسقاء / 6470
It is reported from Sayyiduna Abdullah bin al-Zubayr (may Allah be pleased with him) that whenever he heard the sound of thunder, he would stop talking and say: 'Subhana alladhi yusabbihu al-ra'du bi-hamdihi wa al-mala'ikatu min khifatih' (Glory be to the One whom "the thunder glorifies with His praise, and the angels (too) out of fear of Him" [Surah al-Ra'd: 13]). Then he would say: "This is a severe threat of Allah Almighty for the people of the earth."
Hadith Referenceالسنن الكبرى للبيهقي / كتاب صلاة الاستسقاء / 6471
Ibn Uyaynah (may Allah have mercy on him) said: I said to Ibn Tawus (may Allah have mercy on him): What did your father say when he heard the sound of thunder? He said: He used to say: 'Subhana man sabbahta lah' (Glory be to the One whom you have glorified).
Imam al-Shafi'i (may Allah have mercy on him) said: It is as if he was going by the words of Allah Almighty: "And the thunder glorifies with His praise" [Surah al-Ra'd: 13], that thunder glorifies Allah.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب صلاة الاستسقاء / 6472