The Gemara in Masechet Berachot 59A instructs that upon seeing a rainbow one must recite the Beracha, "Baruch Ata Hashem Elokeinu Melech Ha'olam Zocher Ha'berit, Ne'eman Bi'berito, Ve'kayam Be'ma'amaro." This Beracha thanks God "who remembers the covenant, is loyal to His covenant, and fulfills His word." After God brought the deluge that destroyed the earth during the time of Noach, He made a covenant with Noach to never again bring such devastation to the world, and He designated the rainbow as the sign of this promise. Therefore, upon seeing a rainbow, we give thanks to the Almighty for keeping this promise and maintaining the world despite our unworthiness. We emphasize that God not only "remembers" and "is loyal to" this promise, but also "fulfills His word" regardless of a formal covenant. Even had He not made a visible sign of this promise, He could be trusted to abide by His word and to never again bring a deluge upon the earth as He did in the time of Noach. (Shulchan Aruch 229:1)
One recites this Beracha even if he sees just part of the rainbow, and not the complete arch. See Birkat Hashem, Helek 4, page 311, note 129. The Gemara in Masechet Chagiga 16A comments that one should not stare at a rainbow, as it is a manifestation of the Shechina (the Divine Presence), adding that a person who stares at a rainbow runs the risk of losing his vision, Heaven forbid. A person should instead briefly look at the rainbow and then recite the Beracha.
If a person sees a rainbow, should he inform others about its appearance?
The Mishna Berura (ibid SíK 1) (commentary to the Shulchan Aruch by Rabbi Yisrael Meir Kagan, the "Chafetz Chayim," Lithuania, 1835-1933) and the Kaf Ha'chayim (ibid SíK 1) (by Rabbi Yaakov Hayim Sofer) write that one may not inform others of a rainbow's sighting. The appearance of a rainbow is an ominous sign for mankind, indicating that God's wrath has been aroused and He would destroy the world once again if not for His promise to Noach. Given the general principal of "Motzi Diba Kesil Hu" ("He who bears bad tidings is a fool"), that one should not convey sorrowful news, these authorities maintain that one may not inform others of the sighting of a rainbow.
By contrast, Chacham Ovadia Yosef in Yalkut Yoseph, Helek 3, page 626 that to the contrary, it would be a Mitzvah to inform others of the appearance of a rainbow in the sky. For one thing, they argue, conveying this information enables people to perform the Mitzva of reciting a Beracha. Furthermore, given the fact that a rainbow signals divine wrath, the sighting of a rainbow inspires a person to perform Teshuva and improve his conduct. Therefore, it is laudable to inform other people of the sighting of the rainbow, so as to enable them to recite the Beracha and inspire them to perform Teshuva. (Birkat Hshem, ibid page 312.)
Summary: One who sees a rainbow or part of a rainbow recites the Beracha, "Baruch AtaÖZocher Ha'berit, Ne'eman Bi'berito, Ve'kayam Be'ma'amaro," and it is a Mitzva to inform others about the rainbow's appearance. One should not, however, stare at a rainbow; he should instead look at it briefly and then recite the Beracha.