I have seen several accounts of ancient poetic meters, but it just occurred to me that none of them discussed the origin of the information. Where does our knowledge of the ancient poetic meters come from? Was the theory explained by ancient grammarians or other theorists, or was the system analyzed and reconstructed later from the poems themselves?
If the answer is different for different meters or the situation is otherwise complicated, an overview would be great. Currently I find the big picture more interesting than the specifics since I know almost nothing.
I know how to read or compose in elegiac couplet or Sapphic stanza, for example, but I do not know how this information reached our era.