To start with, you need the connection to be torsion free. After that, there is a characterisation of metric connections given by Schmidtthere is a characterisation of metric connections given by Schmidt, CMP 29 (1973) 55-59, which states that the linear torsion-free connection is metric if and only if the holonomy group is a sub-group of the orthogonal group of the desired signature.
The link was broken. I wasn't sure if I should change the link to the actual pdf or if I should link to the Springer hosting page, here https://link.springer.com/article/10.1007/BF01661152 I assume the hosting page is better actually