I thought it was just light? Light bounces off of different molecules differently?
For example, passing light through a hydrogen gas cloud will remove some red/IR wavelengths from the end result.
We can measure those missing wavelengths and figure out what gasses it's passed through