There are a few signs of a tank which is about to fail. Unfortunately, how long until failure is not so easy to determine.
Leaks
Leaks are perhaps the most obvious, although maybe not the easiest to spot since the water may be dried up. Check the seam of the side of the tank, as well as on the top and bottom. Look for rust, or actively dripping water. Check the pan under the tank, if installed, for signs of water, especially water that has dried.
Full of sediment
If you hear popping or gurgling when the heater is on, that could be a sign that the tank is filling up with (or already full of) sediment. If you don't get as much hot water as you used to, that can also be a sign.
Check the anode rod
Tanked water heaters come with 1 or more anode rods, which protect the heater by dissolving before the tank itself does. Because the metal tank is in contact with water, it begins to dissolve; the anode rod prevents that essentially by dissolving first. This is the cause of some of the sediment build up in the tank (the rest being from the minerals in the water, or from the pipes themselves). If you check your anode rod and it's completely dissolved, you'll need to replace the tank soon as it has already started to corrode; if it's not completely dissolved, you could replace the anode rod and extend the life of the tank.
The water isn't (as) hot anymore
If it's not heating the water (as well as it used to) anymore, you'll need a new water heater, or at least repairs to your existing one.
Water not always being as hot, or needing to run it longer before it runs hot, may not always indicate a failing heater, though. Those things may be affected by the ambient temperature, how well the pipes are insulated, how far from the heater the fixture is, debris in valves or fixtures, etc. If it is a constant problem, that's more likely to indicate a problem with the heater, but if it only happens sometimes, I'd try to rule out other correlations first.
It hasn't failed, but is an energy hog
It may be more energy efficient to replace the water heater even before it has failed, although that depends on the efficiency of your current heater, energy prices, etc. You'd want to run some calculations to see if this is a reasonable option.