Add some metric query helpers

This adds some metric query helpers.

I'll be using these in the http handlers I'll be creating next; just putting these in a separate PR in order to make reviewing easier.