The Messenger of Allah ﷺ said, "Indeed, some poetry contains wisdom."
حدثنا قتيبة حدثنا أبو عوانة عن سماك بن حرب عن عكرمة
قال رسول الله ﷺ إن من الشعر حكما
No references are available.
[Hasan]. Abu Dawud also narrated it in the Book of Manners, the chapter on what has been said about poetry, no. 5011, from the hadith of Abu Awana with the same wording, and the hadith has supporting narrations.