I've implemented something very similar at work, this was a nice write-up. Biggest differences we're doing is to use Welford's algorithm[0] to calculate a running variance, so we can calculate anomalies in real time, without the need to store logs. It works quite well.
[0]: https://en.m.wikipedia.org/wiki/Algorithms_for_calculating_v...