I think an ultrasonic transducer strapped to the outside of the pipe as DrG's earlier post shows would work well.
The echo from the opposite wall of the pipe will take longer through air than through liquid.
Or two transducers, top & bottom, and measure the delay from transmit on one to receive on the other.
The speed of sound in air is around 350 M/Sec while in water it's near 1500 M/Sec. The same numeric values apply for millimetres per millisecond, so very easy to measure with any general microcontroller.
Surely it can be a solution, perhaps too expensive, I would have thought of a solution with two diametrically opposed portholes OB1 and OB2, from OB1 I send a beam of light towards OB2, on OB2 I put a photoresistor and the game "should" be done.
Sensor Type: Position Sensor. Output way: Analog Sensor.
www.ebay.co.uk
And a microcontroller plus a dozen or two small components.
Even simpler, if these ready built ranging modules also use 40KHz transducers, you could likely just connect the metal face ones instead on flying leads and connect to an arduino or similar.
**broken link removed**