Deploying Prometheus and Grafana on Kubernetes

Monitoring a Kubernetes Cluster is the need of the hour for any application following a microservices architecture. There are a bunch of solutions that one can implement to monitor their Kubernetes workload and one of them is Prometheus and Grafana. This article will help you to deploy Prometheus and Grafana in your kubernetes cluster with the help of prometheus-operator.

But before setting up these components let’s understand a bit about each of them.


Prometheus is a pull-based open-source monitoring and alerting tool originally built by SoundCloud. It works on a time-series database and scrapes metrics at a given interval from HTTP endpoints. After Kubernetes, Prometheus joined the Cloud Native Computing Foundation in 2016 as the second hosted project.


The Alertmanager takes care of alerts sent by alerting tools such as the Prometheus server. It handles grouping, silencing, and routing them to the correct receiver integration such as email, PagerDuty, Slack, etc. It also supports the inhibition of alerts.


Grafana is the visual representation of metrics collected by a data source which in our case happens to be Prometheus. We can create or import dashboards for grafana which will make use of promQL to visually represent metrics collected by Prometheus.

Deploy Prometheus-Grafana on Kubernetes

To deploy prometheus-grafana stack on kubernetes we will make use of the kube-prometheus project. The kube-prometheus project is designed for kubernetes cluster monitoring and is customized to collect metrics from all Kubernetes objects, with a bunch of dashboards for Grafana and alerting rules for Alertmanager.

Also, in this tutorial, we will be using minikube to deploy all the resources but you can follow along with any Kubernetes cluster. Now, let’s get started.

Step 1 – Clone the kube-prometheus project.

Step 2 – Apply the server-side manifests.

Step 3 – Apply the monitoring stack manifests.

To see all the resources deployed by the above commands use:

kubectl get all -n monitoring

Accessing Prometheus, Alertmanager, and Grafana through UI.

To access these resources through UI we would have to change the service type from ClusterIP to NodePort.

kubectl edit svc grafana -n monitoring

If you are using minikube run the following command to access Grafana Dashboards in your browser.

minikube service grafana --url -n monitoring

Paste this url in your browser window to open Grafana.

By default, the username and password are set to admin, and on your first login, you will be asked to update that. After that, you will be able to access the Dashboards.


Now repeat the same steps for Prometheus and Alertmanager. Edit the service prometheus-k8s for prometheus and alertmanager-main for alertmanager.



Kube-prometheus stack makes use of stateful sets for prometheus and alertmanager. Since both of them are stateful applications, deployment for grafana and kube-state-metrics as both are stateless applications and daemonset for node exporter as it has to be deployed on every node. In this blog, we learned how to deploy prometheus-grafana stack on kubernetes with kube-prometheus stack telling about the components, and in the next part of the blog, we will dive into detail about the setup and rules.

Blog Pundits: Deepak Gupta and Sandeep Rawat

OpsTree is an End-to-End DevOps Solution Provider.

Connect with Us

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: