Sahih Muslim 4929
The Book on Government
حَدَّثَنَا شَيْبَانُ بْنُ فَرُّوخَ، حَدَّثَنَا حَمَّادُ بْنُ سَلَمَةَ، حَدَّثَنَا ثَابِتٌ، عَنْ أَنَسِ بْنِ مَالِكٍ، قَالَ قَالَ رَسُولُ اللَّهِ صلى الله عليه وسلم " مَنْ طَلَبَ الشَّهَادَةَ صَادِقًا أُعْطِيَهَا وَلَوْ لَمْ تُصِبْهُ " .
It has been narrated on the authority of Anas b. Malik that the Messenger of Allah (may peace he upon him) said:Who seeks martyrdom with sincerity shall get its reward, though he may not achieve it
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.