Sahih al-Bukhari, Book 78, Hadith 171 (Bukhari 5912)

Narrated Ubai bin Ka`b:

Allah's Messenger (ﷺ) said, "Some poetry contains wisdom."