How did the Sages know the names of particular angels?

There have been special individuals in history who reached the level of perfect righteousness (to the extent that it is possible for a human to be perfect). When a person reaches a certain high level of spiritual perfection, he or she is rewarded by G-d with a spirit of prophecy, so that his or her awareness is no longer limited to the physical world, but the heavenly realms and/or the heavenly beings are also revealed, which may be with open sight, prophet vision or intellectual insight. Examples are the righteous heroes and heroines of the Torah, the Hebrew Prophets, and select Sages over the course of history. There were also Gentiles who reached this level. For example we see in Genesis that when Hagar was sent away, she was met by several angels. (Gen. 16:7-13) Why was she not afraid? Because she was used to seeing angels in the home of Abraham and Sarah. There are many many other examples of prophets who personally encountered angels (Isaac, Jacob, Moses, Aaron, Joshua, Jeremiah, Isaiah, Ezekiel, etc.) So ultimately, the knowledge which the Sages had of angelology was based on the personal prophetic experiences and insights of special individuals.