https://www.webmd.com/brain/restless-legs-syndrome/restless-legs-syndrome-rls
Could possibly be a reaction to ambien. Probably not too common of one or it wouldn't be that great of a sleep aid. Although there is also a chance that something else caused it and the ambien is a coincidence.
You probably already know this, but there's a lot things that mess with ones ability to fall asleep. The most important ones are to have a silent, dark, cold and clean room to sleep in. Probably a good idea to clean your self and the bedsheets once in a while too. Then you should always try to get some sunlight during the day and stay away from the computer during night. Computer screens have the same blue-ish color as daylight which will make the brain think it's still daytime. I get bored as hell doing nothing while waiting for falling asleep so i have f.lux and brightness slider to make the screen super orange and dark so i can watch Star Trek untill im gone. But yeah, sometimes that doesn't work either so i take another half pill and just turn off the lights and computer and wait.