Track alerts over time and write out alert timeseries.

This change started out small, but the delta is blown up by:

- necessary test refactorings
- moving RecordingRule and AlertingRule implementations into their own files