How can I treat my insomnia?

Depends. Depends on if the insomnia is due to stress, psychiatric disorder, a primary sleep disorder, another medical condition, medications or poor sleep hygiene. The best treatment is addressing the reasons for the insomnia. Chronic insomnia is best treated with a behavioral program called cbt. Medications are usually indicated for short term use.
Melatonin. Try 3mg of melatonin first. Good sleep hygiene, go to bed early and wake up early. No napping during the day. Engage in exercise so it will tire you out. Once you get your sleep pattern in order, cut out the melatonin slowly or even if you stay on it, no harm has been shown!