2 min read | by Jordi Prats
Prometheus is an open-source systems monitoring and alerting toolkit that users a multi-dimensional data model with time series data identified by metric name and key/value pairs.
The Prometheus operator is a Kubernetes operator that simplifies the provision and management of Prometheus instances on Kubernetes. It provides easy management of Prometheus instances as native Kubernetes resources, and also includes a built-in service discovery mechanism to automatically discover and monitor Kubernetes services.
We can use helm to install the Prometheus operator as follows:
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts helm repo update helm install prom-op prometheus-community/kube-prometheus-stack -n prometheus --create-namespace
By default, it will install an initial prometheus instance:
$ kubectl get pods NAME READY STATUS RESTARTS AGE prom-op-grafana-7c5bcc4888-sw6rb 0/3 ContainerCreating 0 19s prom-op-kube-prometheus-st-operator-5c9cbd755b-4q4tb 0/1 ContainerCreating 0 20s prom-op-kube-state-metrics-776db89f58-2p7mt 0/1 ContainerCreating 0 20s prom-op-prometheus-node-exporter-wps64 0/1 ContainerCreating 0 20s
To be able to reach this initial instance we can use kubectl port-forward to
kubectl -n prometheus port-forward svc/prometheus-operator-prometheus-prometheus 9090
Once you have port-forwarded the Prometheus service, you can access the Prometheus UI by visiting
http://localhost:9090 in your web browser.
The Prometheus operator also comes with preconfigured Grafana dashboards for visualizing metrics. You can access Grafana by port-forwarding the Grafana service using kubectl port-forward to
kubectl -n prometheus port-forward svc/prom-op-grafana 3000
For grafana, you'll be able to reach it using
Overall, the Prometheus operator is a powerful tool for monitoring your Kubernetes cluster and its applications. With its easy installation process and preconfigured dashboards, it's a great way to get started with monitoring very quickly.
Posted on 04/04/2023