How to measure dry cell charge level
See the wikipedia article for Alkaline battery for an exemplary discharge vs voltage table:



The data is from TI's SLVA194 (I think that'd be an interesting read for you!); the basic idea is this:

If you roughly know the load current, you can measure the voltage of the battery (using your microcontroller's ADC or an external ADC – the hard part might be getting a battery-independent reference voltage) and infer the charge state from that pretty simply by looking it up in a table as the above; discharge curves (from the same TI document) look like this:



This all starts with you specifying the minimal voltage your battery still needs to supply for your device to work – if you need 1.35V, your battery will be depleted much earlier than if you can still work with 1.10V.

Generally, don't expect multiple significant digits – these curves depend on the battery, on how your current draw distribution over time looks like, and very significantly on temperature. Think of this more in terms of "nearly full", "two thirds", "one third", "nearly empty – replace now". You really can't do much better without testing every battery model you use yourself, and very closely controlling the environment in which the battery works.