1. A chemical mechanical polishing system, comprising: a platen to hold a polishing pad; a carrier head to hold a substrate in contact with the polishing pad; an in-situ optical monitoring system configured to measure a sequence of spectra of light from the substrate while the substrate is being polished; and a controller configured to receive an identification of a selected spectral feature and a characteristic of the selected spectral feature to monitor during polishing, receive the sequence of spectra of light from the in-situ monitoring system, for at least some spectra in the sequence, dynamically generate a wavelength range based on a position of the spectral feature in a previous spectrum in the sequence of spectra, for each spectrum of the at least some spectra in the sequence, search the dynamically generated wavelength range of the spectrum for the spectral feature and determine a value of the characteristic of the selected spectral to generate a sequence of values, and determine at least one of a polishing endpoint or an adjustment for a polishing rate based on the sequence of values.