spreaker / aws-cloud-unmap

External controller to remove terminated EC2 instances from AWS Cloud Map service
MIT License
11 stars 4 forks source link

Export prometheus metrics #6

Closed pracucci closed 5 years ago

pracucci commented 5 years ago

In this PR I've introduced a built-in Prometheus exporter and two exported metrics, that will help us in alerting:

A note about tests: Prometheus client for Python does allow to start_http_server, but not to stop the HTTP server. So in tests I'm not enabling it via --prometheus-enabled because the second execution of main() will fail to bind the Prometheus exporter port (already binded by the first execution of main()), but I'm always setting the internal Prometheus metrics if when Prometheus is not enabled, so that I can assert on them. All in all, the --prometheus-enabled flag just turn on the HTTP server of the built-in exporter.