Caution: Translations of Quran and Ḥadīth may lead to possible misapplications and misinterpretations. This site is intended for students of sacred knowledge that are proficient in comprehending classical Arabic and have a strong foundation in Islamic sciences. Also note that religious injunctions rely on several aspects beyond what one may glean through reading individual aḥādīth.
ahmad-zuhd:457ʿAbdullāh > Bī > ʿAffān > al-Mubārak b. Faḍālah > al-Ḥasan

[Machine] I heard Al-Hasan saying: Whenever a calamity would befall Prophet Ayyub, ﷺ , he would say, "O Allah, you have taken away and you have given, and whatever remains with me, I thank you for the goodness of your trials."  

الزهد لأحمد:٤٥٧حَدَّثَنَا عَبْدُ اللَّهِ حَدَّثَنِي أبِي حَدَّثَنَا عَفَّانُ حَدَّثَنَا الْمُبَارَكُ بْنُ فَضَالَةَ قَالَ

سَمِعْتُ الْحَسَنَ يَقُولُ كَانَ أَيُّوبُ عَلَيْهِ السَّلَامُ كُلَّمَا أَصَابَتْهُ مُصِيبَةٌ قَالَ «اللَّهُمَّ أَنْتَ أَخَذْتَ وَأَنْتَ أَعْطَيْتَ مَهْمَا تُبْقِي نَفْسِي أَحْمَدُكَ عَلَى حُسْنِ بَلَائِكَ»