who discovered it?
Abd al-Rahman al-Sufi.
Andromeda Galaxy
Around the year 964, the Persian astronomer Abd al-Rahman al-Sufi was the first to describe the Andromeda Galaxy. 
who measured the distance to the andromeda galaxy to be over a million light years UNANSWERABLE what is it made up of ? Metals and gases. when was it discovered? Around the year 964.
wiki:13496144
Andromeda Galaxy [SEP] Observation history
Around the year 964, the Persian astronomer Abd al-Rahman al-Sufi was the first to describe the Andromeda Galaxy. He referred to it in his "Book of Fixed Stars" as a "nebulous smear". Star charts of that period labeled it as the "Little Cloud". In 1612, the German astronomer Simon Marius gave an early description of the Andromeda Galaxy based on telescopic observations. Pierre Louis Maupertuis conjectured in 1745 that the blurry spot was an island universe. In 1764, Charles Messier cataloged Andromeda as object M31 and incorrectly credited Marius as the discoverer despite it being visible to the naked eye.