While the previous comments seem to be blaming the battery, if I'm reading your thread correctly, it sounds like you are charging it overnight. In order to really help you we will need some answers and more details.
First what device do you have?
Do you have any kind of auto restart or power off timer set? On my Samsung the auto restart can be set for as often as I want I believe but I only have it set for once a week. Have you checked this or for this setting?
If the restarts are not intentional or accidentally set to be intentional, are you telling us that your device turns itself off even when on the charger? If this is what is happening the alarm is the least of your issues. This is a far bigger one that needs to be addressed before we go any farther. It could be the battery, the charger, the charging cable, the port, any number of things.
Now it's your turn, offer some input to get better advice...