If one eats a meal on Chanukah, minhag has it that ve-al ha-nissim is included in the Birkat Ha-mazon, though the Talmud clarifies that this is not a halachah. Because it is minhag if one forgets to recite ve-al ha-nissim one is neither required nor permitted to repeat the Birkat Ha-mazon. The Rema comments that in such a case, the minhag dictates that one add on among the various Harachaman prayers, "Harachaman yaaseh lanu nissim veniflaot keshem sheasita la-avoteinu bayamim hahem bazman hazeh," and then continue to recite "Beyemei Matityahu.."
The commentaries on the Shulchan Aruch raise a question: how is it permissible to ask for a miracle to occur? Doesn't the Mishna in Berachot state that if a pregnant woman is already past the first forty days of her pregnancy, and the sex of the baby has already been determined, that one may not pray for a miracle and ask for a baby of a specific gender?
The Shaarei Teshuvah quotes the three exceptions to the rule as stated by the Acharonim, as to when one is permitted to ask for a nes: 1) One may ask for a nes nistar. For this is what hashgacha is all about- God controls the world from behind the scenes, without openly violating any of the rules of nature. 2)Since we believe that, "ein mazal le-yisrael," that the Jewish people are, "lemala min hateva," there is nothing at all improper about requesting a nes nigleh on their behalf. 3) Even if the nes is not for Klal Yisrael, but only on behalf of an unusual tzadik, this too is allowed, as is evidenced from the various stories related in the Gemara Taanit regarding several tzadikim who prayed for miracles. The great tzadik is also "lemala min hateva."
In Parshas Korach we find Moshe Rabbeinu requesting of God that even if the opening of Gehenom is not here, that He make a nes and "yivra Hashem" - make it move to here. Because the miracle was needed- either for klal yisrael or the unusual tzadik- Moshe was allowed to pray for it.
A similar situation appears in the Haftorah. Shmuel Ha-navi calls upon God to bring about a miracle on Shmuel's personal behalf, to indicate his righteousness. This appears to be the thematic similarity between the sedra and the Haftorah: the exceptions to the rule i.e. when one is permitted to pray for a miracle.
To illustrate this point, I remember many years ago, when I visited the Ponovez Yeshina in Benai Brak, the tzibbur was reciting tehillim on behalf of a cancer patient on whom the doctors had given up hope. The Mashgiach, Rav Yecheskel Levenstein - refused to participate in the prayers because in effect they were praying for a miracle.