Sunan Ibn Majah, Volume 5, Book 33, Hadith 3804 (DarusSalam) ⓘ
It was narratd from Abu Hurairah that : the Prophet used to say: "Al-hamdu lillahi 'ala kulli hal. Rabbi a'udhu bika min hali ahlin-nar (Praise is to Allah in all circumstances, O Allah, I seek refuge with You from the situation of the people of Hell)."
حَدَّثَنَا عَلِيُّ بْنُ مُحَمَّدٍ، حَدَّثَنَا وَكِيعٌ، عَنْ مُوسَى بْنِ عُبَيْدَةَ، عَنْ مُحَمَّدِ بْنِ ثَابِتٍ، عَنْ أَبِي هُرَيْرَةَ، أَنَّ النَّبِيَّ ـ صلى الله عليه وسلم ـ كَانَ يَقُولُ " الْحَمْدُ لِلَّهِ عَلَى كُلِّ حَالٍ رَبِّ أَعُوذُ بِكَ مِنْ حَالِ أَهْلِ النَّارِ " .
also referenced under: Hadith 3804 (Reference) & Book 33, Hadith 149 (In-Book)