An elegy is a poem for a sad occasion/death, similar to requiem, dirge or threnody
a song or hymn of mourning composed or performed as a memorial to a dead person
See also: dirge coronach lament requiem