Spectroscopy is the study of light as a function of length of the wave that has been emitted, reflected or shone through a solid, liquid, or gas.
To be analysed the chemical is heated, because each chemical glows differently. The various wavelengths of the glow make a color spectrum which differs in some detail from other chemicals. Spectroscopy separates and measures the brightness of the different wavelengths. It can identify the chemicals in a mixture, and determine some other things, such as how hot the thing is.