It does help a little. However, you may have to take it a couple hours before you go to bed and you will need a good 8 hours to sleep (maybe more).
The dosage is a little tricky. Some people can get by with as little as .5 mg (you can get that at trader joes). But some stores will sell up to 5 or 7 mg (which is probably counterproductive... if 3 mg doesn't work, 5 or 7 probably won't either). Melatonin builds up in the system if you take it every day so if it works for you at all try to find the smallest amount that works. I've heard that prolonged use of melatonin can cause depression in some people, but I think other than that it is relatively safe.
If your insomnia is due primarily to anxiety and distracting thoughts, 25 mg - 50 mg of benadryl (or some product with diphenhydramine) may be more helpful. I don't particularly like benadryl though because it causes temporary cognitive decline and worsens depression for me (some people take it every day without a problem, but it isn't recommended for long-term use).
Valerian is safe and marginally helpful but melatonin is more effective for me.
Bottom line, yes, it might be helpful. Don't expect it to knock you out immediately though. It takes some time to work.