كتاب الفتن وأشراط الساعة
54  
The Book of Tribulations and Portents of the Last Hour
(18)
Chapter: The Hour Will Not Begin Until A Man Passes By Another Man's Grave And Wishes That He Was In The Place Of The Deceased, Because Of Calamity
(18)
بَاب لَا تَقُومُ السَّاعَةُ حَتَّى يَمُرَّ الرَّجُلُ بِقَبْرِ الرَّجُلِ فَيَتَمَنَّى أَنْ يَكُونَ مَكَانَ الْمَيِّتِ مِنْ الْبَلَاءِ
Sahih Muslim 2915 a

Abu Sa`id Khudri reported:

One who is better than I informed me, that Allah's Messenger (ﷺ) said to `Ammar as he was digging the ditch (on the ocassion of the Battle of the Ditch) wiping over his head: O son of Summayya, you will be involved in trouble and a group of the rebels would kill you.
حَدَّثَنَا مُحَمَّدُ بْنُ الْمُثَنَّى، وَابْنُ، بَشَّارٍ - وَاللَّفْظُ لاِبْنِ الْمُثَنَّى - قَالاَ حَدَّثَنَا مُحَمَّدُ، بْنُ جَعْفَرٍ حَدَّثَنَا شُعْبَةُ، عَنْ أَبِي مَسْلَمَةَ، قَالَ سَمِعْتُ أَبَا نَضْرَةَ، يُحَدِّثُ عَنْ أَبِي سَعِيدٍ الْخُدْرِيِّ، قَالَ أَخْبَرَنِي مَنْ، هُوَ خَيْرٌ مِنِّي أَنَّ رَسُولَ اللَّهِ صلى الله عليه وسلم قَالَ لِعَمَّارٍ حِينَ جَعَلَ يَحْفِرُ الْخَنْدَقَ وَجَعَلَ يَمْسَحُ رَأْسَهُ وَيَقُولُ ‏ "‏ بُؤْسَ ابْنِ سُمَيَّةَ تَقْتُلُكَ فِئَةٌ بَاغِيةٌ ‏"‏ ‏.‏
Reference : Sahih Muslim 2915a
In-book reference : Book 54, Hadith 86
USC-MSA web (English) reference : Book 41, Hadith 6966
  (deprecated numbering scheme)