Some time last year Prometheus became a technical preview for Openshift. That same month I rolled onto a project with some pretty steep architectural layouts of handling metrics. I spent several sprints hacking out of the box features and configurations into Openshift’s Prometheus deployment. All of this changed towards the end with the introduction of the Monitoring Operator. I’ll be writing about that at a later date, I’m still working out some kinks in my home lab.
Prometheus is an open-source systems monitoring and alerting toolkit originally built at SoundCloud. Since its inception in 2012, many companies and organizations have adopted Prometheus, and the project has a very active developer and user community. It is now a standalone open source project and maintained independently of any company. To emphasize this, and to clarify the project’s governance structure, Prometheus joined the Cloud Native Computing Foundation in 2016 as the second hosted project, after Kubernetes.
Pretty juicy toolset. Ships with alerting, scales well, and focuses on reliability. There are some caveats consumers need to be aware of, though. In particular certain aspects are left in their responsibility.
Use: I want to take detailed metrics of this ec2 instance. I have a Kubernetes cluster running on an array of Raspberry Pi’s in my apartment. This has its own dedicated storage (Containerized Gluster). Metrics are pretty storage intensive, and storage is expensive in the cloud.
Architecture: Prometheus can scrape another instance of Prometheus and apply labels. I can have a small data retention policy on the cloud instance, and a large one on my on site instance.
Problem: Prometheus isn’t secured out of the box. I need my metrics behind some sort of gateway, and it’s best I use HTTPS.
First install Prometheus. This varies by OS. The docs recommend a manual installation, but I was able to apt-get them on Ubuntu.
There are additional exporters listed here.
The Ubuntu package comes as an init.d script so I quickly wrote a Service for Prometheus so I could pass some CLI flags. I didn’t bother for the node exporter since it did what I wanted out of the box.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
I can fire this up now and expose a port of my choice but it’d be open to the public. Let’s instead reverse proxy with HTTPS and password auth. Inside my virtualhost I added:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
Last, let Prometheus know where to find itself to gather metrics on itself.
1 2 3 4 5 6 7 8 9 10 11 12 13
The web URL parameter let Prometheus know to redirect properly. Hit the URL to impress your project managers.