charmed-lma / charm-k8s-prometheus

Kubernetes Operator for Prometheus
Apache License 2.0
4 stars 2 forks source link

Add interface for retrieving alerting config from charmed AlertManager #14

Closed relaxdiego closed 4 years ago

relaxdiego commented 4 years ago

This commit allows the charm to retrieve a configuration string from the alertmanager charm. The configuration string is a JSON string that this charm converts to a dict that is then inserted to another dict that ultimately gets serialized into a YAML-formatted prometheus config file.

While this charm is agnostic to the contents of the JSON string, in AlertManager's current iteration, it uses the kube_sd_configs method so that Prometheus can quickly detect changes in the number of AlertManager pods without waiting for any Juju events.

relaxdiego commented 4 years ago

This initial commit uses service discovery to automatically detect available alert managers. It does not yet filter for namespace and such but will in future commits. The configuration is via a static file at the moment but this is just an interim step. Ideally it should come from an interface which I will add soon.

For now, once you deploy this charm as well as https://github.com/relaxdiego/charm-k8s-alertmanager, then heading to the /status path of the prometheus GUI will list the alertmanager(s) endpoints under the Alertmanager section.

relaxdiego commented 4 years ago

Thanks for the review @exceptorr! Will address them now.