Worth noting that, at one point, Germany, Russia, and Austria-Hungary were much closer than they were at the onset of WW1. There had in fact existed an unofficial concord known as the League of Three Emperors, created by Bismarck in 1873 to protect Germany from two of its perceived biggest threats (the other being France). The biggest element of the league was that the leaders of the nations involved would consult each other before making decisions regarding territorial claims.
The league collapsed in 1887 due to unrecconcilable disputes in the Balkans between Russia and Austria-Hungary. Consequently, Bismarck engineered the Reinsurance Treaty with Russia: a secret, mutual pact of non-aggression that guaranteed that the two countries would remain neutral if the other was attacked by one of the other Great Powers (with a stipulation that it would be rendered void if Russia attacked Austria-Hungary or Germany attacked France).
But after Kaiser Wilhelm took power and dismissed Bismarck, he refused to renew the Reinsurance Treaty. This sent a skittish Russia (which had been weakened by internal divisions) running to France, forming the beginning of that alliance.
Source: The War That Ended Peace