The Prophet ﷺ used to say, "Indeed, some poetry contains wisdom."
حدثنا أبو بكر حدثنا أبو أسامة عن زائدة عن سماك عن عكرمة
أن النبي ﷺ كان يقول إن من الشعر حكما
No references are available.
Chain of transmission, hasanAbu Dawud narrated it in the Book of Manners, Chapter on What Has Been Said About Poetry, no. 5011, from the hadith of Simak, with this wording. Tirmidhi said, no. 2845, hasan sahih, though its chain of transmission is not strong. Refer to no. 171, and the preceding hadith serves as a supporting witness for it.