I have been having periods of interrupted sleep for the past two weeks. I am taking melatonin to help me sleep which stopped working what should I do?

Melatonin tolerance? Consider increasing the melatonin, doses of 3 - 9 mg effective in adults. Paradoxically, it could actually be making sleep worse - so consider stopping it for a few days. Your sleep may return to normal. Although melatonin can sometimes work for RLS type sleep disorders, if prototypical symptoms use Dopamine agonists, gabapentin, Baclofen or opiates. If snoring oximetry to screen for apnea.
Find the cause. It seems that you have a temporary problem more than likely caused by a recent change in your life circumstances. Answering your question requires a lot more information. Melatonin is not a sleeping pill. Don't self medicate. Talk to your doctor or to a sleep specialist.
Sleep hygiene. There are many reasons for interrupted sleep. Be sure you have a regular sleep schedule and routine. Your room and bed should be a restful place, free of distraction and stresses. Don't eat in bed, work in bed, or watch tv while in bed for example. If you've done all you can on the sleep hygiene front, consult a physician. A sleep study may be indicated or short term sleep medications.