undervalued overall, just like individual stocks. It is fairly easy to tell how much, just by looking at historical averages — and the market always tends to regress toward the mean, eventually. Price/earnings ratio is the most popular valuation tool.
The market is more likely to be overvalued when it is at or near record highs, but not necessarily. Sometimes it is fairly valued, by historical standards, even at market peaks. Other times, valuations are very high even when the market is not at a peak.
I don’t recommend trying to time the market, but if your investment horizon is less than 8-10 years, it’s not a bad idea to shift asset classes or types somewhat and underweight stocks when the market is clearly overvalued, or overweight stocks when the market is undervalued.
If your investment horizon is more than 8-10 years, then I would just stay fully invested in stocks regardless of overall market valuation.