Difficulty: beginner
Estimated Time: 10-15 minutes

BoxBoat Logo

Monitoring Kubernetes with Prometheus

In this scenario you'll have an environment with a running Kubernetes cluster, Helm installed, and PVs available. We will cover:

  • Installing Prometheus
  • Configuring Prometheus (and Alertmanager)
  • Alerting on a metric
  • Forward an alert

NOTE: This Katacoda scenario is an accompanying resource to a BoxBoat blog post on getting started with Prometheus monitoring: http://boxboat.com/2019-07-08-monitoring-kubernetes-with-prometheus/

Let's get started by installing Prometheus.

Please email feedback to: [email protected]

Congratulations -- by monitoring and alerting on troublesome metrics, you've gained a whole new insight into your Kubernetes cluster and the state it's currently in.

Monitoring Kubernetes with Prometheus

Step 1 of 3

Installing Prometheus

Since we're using Helm, we can install Prometheus straight from the stable/prometheus chart.

Before we do that, that's make sure Helm is initialized and the repos are upto date.

helm init
helm repo update
helm install --name prometheus stable/prometheus

Now let's check on our new pods and make sure everthing went smoothly.

kubectl get pods

If you're fast enough, the pods won't be ready and you might have to run the command above multiple times.

NOTE: If, however, our prometheus-alertmanager- and prometheus-server- pods are still in the Pending state, then you might have a problem with your PVCs. Check the blog post for more details on how to fix that.

Exposing the dashboards

At the end of our helm install command, we're given instructions on how to expose the Prometheus and Alertmanager dashboards. Let's execute those commands now.

kubectl port-forward --address svc/prometheus-server 9090:80 >/dev/null &
kubectl port-forward --address svc/prometheus-alertmanager 9093:80 >/dev/null &

Now we should be able to access the dashboards at the top of your terminal labelled "Prometheus" and "Alertmanager".

Awesome! Let's move on to configuring Prometheus.