Context. The carbon monoxide (CO) molecular line at around 46655 A in solar infrared spectra is often used to investigate the dynamic behavior of the cold heart of the solar atmosphere, i.e., sunspot oscillation, especially at the sunspot umbra. Aims. We investigated sunspot oscillation at Doppler velocities of the CO 7-6 R67 and 3-2 R14 lines that were measured by the Cryogenic Infrared Spectrograph (CYRA), as well as the line profile of Mg II k line that was detected by the Interface Region Imaging Spectrograph (IRIS). Methods. A single Gaussian function is applied to each CO line profile to extract the line shift, while the moment analysis method is used for the Mg II k line. Then the sunspot oscillation can be found in the time-distance image of Doppler velocities, and the quasi-periodicity at the sunspot umbra are determined from the wavelet power spectrum. Finally, the cross-correlation method is used to analyze the phase relation between different atmospheric levels. Results. At the sunspot umbra, a periodicity of roughly 5 min is detected at the Doppler velocity range of the CO 7-6 R67 line that formed in the photosphere, while a periodicity of around 3 min is discovered at the Doppler velocities of CO 3-2 R14 and Mg II k lines that formed in the upper photosphere or the temperature minimum region and the chromosphere. A time delay of about 2 min is measured between the strong CO 3-2 R14 line and the Mg II k line. Conclusions. Based on the spectroscopic observations from the CYRA and IRIS, the 3 min sunspot oscillation can be spatially resolved in the Doppler shifts. It may come from the upper photosphere or the temperature minimum region and then propagate to the chromosphere, which might be regarded as a propagating slow magnetoacoustic wave.