Both "elegy to" and "elegy for" are correct, but they can have slightly different meanings. "Elegy to" suggests that the elegy is addressing something or someone, while "elegy for" indicates that the elegy is in memory or honoring someone or something. Choose the preposition based on the specific context you want to convey.