Sahih Muslim 5889
The Book of Poetry
وَحَدَّثَنِي مُحَمَّدُ بْنُ حَاتِمِ بْنِ مَيْمُونٍ، حَدَّثَنَا ابْنُ مَهْدِيٍّ، عَنْ سُفْيَانَ، عَنْ عَبْدِ الْمَلِكِ، بْنِ عُمَيْرٍ حَدَّثَنَا أَبُو سَلَمَةَ، عَنْ أَبِي هُرَيْرَةَ، قَالَ قَالَ رَسُولُ اللَّهِ صلى الله عليه وسلم " أَصْدَقُ كَلِمَةٍ قَالَهَا شَاعِرٌ كَلِمَةُ لَبِيدٍ أَلاَ كُلُّ شَىْءٍ مَا خَلاَ اللَّهَ بَاطِلٌ وَكَادَ أُمَيَّةُ بْنُ أَبِي الصَّلْتِ أَنْ يُسْلِمَ " .
Abu Huraira reported Allah's Messenger (ﷺ) as saying:The truest word uttered by a poet is this verse of Labid: "Behold! apart from Allah everything is vain," and Umayya b. Abu Salt was almost a Muslim
Text from the public-domain hadith-api dataset. Numbering follows that dataset and can differ by a few from some printed editions — check the wording, not only the number.