Using a few infrared detectors with various wavelengths placed near the intake valve, you could pretty accurately estimate the maximum temperature inside the combustion chamber when the valve opened.
The internals of the combustion chamber would reflect infrared pretty perfectly, allowing it to bounce out of the intake valve while it was opened. The multiple infrared detectors would have overlapping response curves to allow a multi-spectral infrared color estimation. Using the maximum detected color, you could estimate the temperature by comparing it to a blackbody radiator.
The valve-closed levels could be used to cancel any ambient levels, and the signal could be filtered against the changes in intensity from the changes in valve aperture size as the valve opened and closed.
Being near the intake, the sensor might stay clean clean. A window could be placed in the side of the intake pipe to keep the sensor out of harms way, with a light collector of some kind focused on the intake valve.
Maximum temperature is nice to know since it is what would cause any pre-ignition.