Through Ronan and Loki, Thanos at least has a good guess to the location of all but the soul stone.
He spent many years hunting down the stones and his desire to achieve his goal is what led him to forge deals with Loki and Ronan the Accuser in their respective campaigns against Earth and Xandar, as seen in his promising to aid them in exchange for an Infinity Stone. Both of these new alliances cost Thanos much of his resources, including one of the stones and the loyalty of his two daughters, Gamora and Nebula, and inadvertently resulted in the formation of the two superhero groups: the Avengers and the Guardians of the Galaxy. Fed up with these failures of his subordinates, Thanos opted to seek out the six Infinity Stones himself.
Ronan informed Thanos that he has The Orb (the power infinity stone) and that he’s going to Xandar with it based on his quote. That’s the first stone that Thanos recovers before Infinity War starts.
"I will unfurl one thousand years of Kree justice on Xandar and burn it to its core! Then, Thanos, I'm coming for you!” Ronan the Accuser to Thanos
It’s reasonable for Thanos to assume Loki may have the Tesseract based on the events in the first Avengers movie and Thor Ragnarok. We see he’s right at the start of Infinity War.
In 2012, after his defeat at the hands of Thor, Loki came into contact with the alien race known as the Chitauri, and their master, Thanos, who had already been seeking the Tesseract. Loki promised to retrieve it from Earth and give it to Thanos in exchange for his army. Through manipulation of the Tesseract's energy, Thanos teleported Loki to the Tesseract's location at the Joint Dark Energy Mission Facility.
When Loki went into Odin's Trophy Room to retrieve the head of Surtur, he passed by the Tesseract and took it from the vault.
I’m not sure how Thanos identified the Collector as having an infinity stone; but I would suspect the Collector in his own hunt for the other stones was not as careful as he should have been.
Once Malekith was defeated, the Asgardians managed to contain the Aether and, with the Power Stone already in their possession, feared having too many Infinity Stones in one place. Instead, they gave it to the Collector, who promised to look after it – not realising he intended to collect them all himself.
Given the failed invasion of New York and that Loki doesn’t have the scepter, Thanos can assume that the mind stone is still on Earth.
Thanos also provided Loki with a Scepter containing the Mind Stone.
It’s possible that Loki, Kaecilius or Dormammu conveyed to Thanos that the time stone is on Earth. Or given how long the time stone has been on Earth, Thanos could have known about it for centuries.
Strange wore it once again a little while later while meeting with Thor and Loki.
Thor’s vision is what makes me feel Loki had the knowledge about the time stone.
I won’t say I know completely how; but I will say Thanos had means of gaining this information.
Even if it isn't well explained, by the end of Avengers: Age of Ultron, it's clear what Thor learned. He's the first person to connect the gemstone dots.