Escape all illegal chars in metric names.

E.g. right now there are some metrics with dashes in their names, which cannot
be queried through the UI.