Mishkat al-Masabih 2429
وَعَنْ عُمَرَ بْنِ الْخَطَّابِ وَأَبِي هُرَيْرَةَ قَالَا: قَالَ رَسُولُ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ: مَا مِنْ رَجُلٍ رَأَى مُبْتَلًى فَقَالَ: الْحَمْدُ لِلَّهِ الَّذِي عَافَانِي مِمَّا ابْتَلَاكَ بِهِ وَفَضَّلَنِي عَلَى كَثِيرٍ مِمَّنْ خَلَقَ تَفْضِيلًا إِلَّا لَمْ يُصِبْهُ ذَلِكَ الْبَلَاءُ كَائِنا مَا كانَ . رَوَاهُ التِّرْمِذِيّ
From ʿUmar ibn al-Khattab and Abu Hurayrah, who said: The Messenger of Allah ﷺ said: "There is no man who sees someone afflicted and says: Praise be to Allah who has kept me safe from what He has afflicted you with, and has favoured me greatly over many of those He created, except that that affliction will not befall him, whatever it may be." Reported by at-Tirmidhi.