Sochi is generally safe for tourists if you stick to usual safety precautions such as walking in well-lit areas after dark and not getting into cars with unfamiliar people. Petty crime, while still very low, is more common in the south than in Moscow and St. Petersburg, so watch your stuff. Only buy alcohol and food from established vendors, do not buy it on the street. Poisonings by street food or alcohol sold on the streets have occurred.
The regions surrounding Sochi are not so safe, however. Traveling deeper into the Caucasus on your own can be very dangerous. The nearby republics of Kabardino-Balkaria, Ingushetiya, Chechnya, and Dagestan are very beautiful, but the low-level Islamic insurgency taking place there makes travelling to these places a big risk. Chechnya (which fought a bitter war with Russia in the 1990s) and Dagestan are far enough, but should be off limits to travelers with no official business there. Dagestan was recently ranked as the most dangerous place in Europe. The republic sees near-daily violence, including shootouts and explosions.