The Messenger of Allah ﷺ said, "No servant is ever afflicted with anxiety, grief, or sorrow and then says, 'O Allah, I am Your servant, the son of Your servant, the son of Your maidservant. My forelock is in Your hand. Your judgment over me is binding, and Your decree concerning me is just. I ask You by every name that belongs to You, by which You have named Yourself, or which You have revealed in Your Book, or which You have taught to any of Your creation, or which You have kept hidden in the knowledge of the unseen with You, that You make the Quran the springtime of my heart, the light of my chest, the dispeller of my grief, and the remover of my anxiety and sorrow,' except that Allah removes his anxiety and grief and replaces it with joy."They asked, "Messenger of Allah, should we not learn these words?"He replied, "Yes indeed, whoever hears them ought to learn them."
قال رسول الله ﷺ: ما أصاب عبدا قط هم ولا غم ولا حزن، فقال: اللهم إني عبدك، ابن عبدك، ابن أمتك، ناصيتي بيدك، ماض في حكمك، عدل في قضاؤك، أسألك بكل اسم هو لك، سميت به نفسك، أو أنزلته في كتابك، أو علمته أحدا من خلقك، أو استأثرت به في علم الغيب عندك، أن تجعل القرآن ربيع قلبي، ونور صدري، وجلاء حزني، وذهاب همي وغمي، إلا أذهب الله همه وغمه، وأبدله مكانه فرحا قالوا: يا رسول الله، أفلا نتعلمهن؟ قال: بلى، ينبغي لمن يسمعهن أن يتعلمهن.
Ahmad (3712), Abu Yaala (5297), Tabarani in al-Kabir (10/209-210), and Bayhaqi in al-Asma wal-Sifat (7) all narrated it, and Ibn Hibban (972) and Hakim (1/509) graded it sahih, all of them by way of Fudayl bin Marzuk, who said, Abu Salama Juhani narrated to us, from Qasim bin Abdul-Rahman, from his father, from Ibn Masud, and he related it.The discussion of this is set out at length in the book of Iman. There are many hadiths on seeking nearness to Allah through His names and attributes, cited in their proper places.