The Lord Jesus showed Peter that his end was near either by a revelation through the Holy Spirit or by his response to Peter when he said: "Get behind me, Satan" or perhaps by dreams and visions in the night.
Source: INTRODUCTORY COMMENTARY ON 2 PETER