Diagnosis of insomnia typically involves a comprehensive medical history and sleep history. Physicians may use sleep diaries, questionnaires, and, in some cases, [polysomnography](). A polysomnography is an overnight sleep study that records brain waves, oxygen levels, heart rate, and breathing to identify any underlying sleep disorders.