Sometimes I'll hear a Midrash and sometimes people might say, "Well, I don't know if it's meant to be taken literally."
When do we know when Midrashim are speaking metaphorically or when they are telling a real story?
The answer Here here which he says Rambam in the Moreh and the Ramchal are speaking metaphorically
The Vilna Gaon (Even Shelema 8:26 citing his other works) says:
The Midrashim that seem to be nonsense (are not so). Within them is held all the secrets.
Just wanted to add this in.