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:405ʿAbdullāh > Abū Mūsá al-Anṣārī > al-Walīd > Shuʿbah b. ʿAbd al-ʿAzīz

One of the supplications of Prophet David ﷺ was: "Glory be to the One who brings forth gratitude through His gifts, and brings forth supplication through hardships."  

الزهد لأحمد:٤٠٥حَدَّثَنَا عَبْدُ اللَّهِ حَدَّثَنَا أَبُو مُوسَى الْأَنْصَارِيُّ أَخْبَرَنَا الْوَلِيدُ عَنْ شُعْبَةَ بْنِ عَبْدِ الْعَزِيزِ أَوْ غَيْرِهِ قَالَ

كَانَ مِنْ دُعَاءِ دَاوُدَ عَلَيْهِ السَّلَامُ سُبْحَانَ مُسْتَخْرِجِ الشُّكْرِ بِالْعَطَاءِ وَمُسْتَخْرِجِ الدُّعَاءِ بِالْبَلَاءِ