Prometheus and Grafana setup in Minikube


Introduction

In this post I will show you how to deploy Prometheus and Grafana into your Minikube cluster using their provided Helm charts. Prometheus will help us monitor our Kubernetes Cluster and other resources running on it. Grafana will help us visualize metrics recorded by Prometheus and display them in fancy dashboards.

Requirements

  • Minikube
  • helm

Install Prometheus

The stable channel Prometheus charts have been deprecated in favor of the Prometheus Community Kubernetes Helm Charts.

We’ll start by adding the repository to our helm configuration:

Once the repo is ready, we can install the provided charts by running the following commands:

The first command installs the charts. Since we are using Minikube, the second command exposes the prometheus-server Pod using a NodePort. This way we can now easily access the Prometheus web interface when the Pod is ready:

Prometheus Web Interface in Minikube

Install Grafana

As with Prometheus, the stable channel official Helm charts for Grafana have been deprecated. The recommended charts are the ones hosted by the Grafana Community Kubernetes Helm Charts repository.

Same as before, we’ll start by adding the repository to our helm configuration:

Next, we install Grafana by using the provided charts:

Again, since we are using Minikube, in order to easily access Grafana’s Web interface we expose the service as a NodePort.

Note: Grafana is password protected by default, in order to retrieve the admin user password we can run the following command:

We can now load the Grafana web interface using the admin user and the password retrieved:

Grafana Login Web Interface in Minikube

Configure Prometheus Datasource

Once we’re logged in to the admin interface, it’s time to configure the Prometheus Datasource.

We need to head to Configuration > Datasources and add a new Prometheus instance.

Grafana Add Prometheus Datasource

The URL for our Prometheus instance is the name of the service http://prometheus-server:80.

Kubernetes Dashboard bootstrap

Next, we’ll setup one of the many already available community provided Kubernetes Dashboards.

For this blog post I will be using this one https://grafana.com/grafana/dashboards/6417, but you can use any other Dashboard. You can even create your own very easily, but this will be covered in another post.

We head to Create (+) > Import section to Import via grafana.com and we set 6417 into the id field and clock Load.

Grafana Import Dashboard from grafana.com

In the dashboard configuration we need to select the Prometheus Datasource we created in the earlier step.

Grafana import dashboard - configure Datasource

Once we confirm the Import dialog, we’ll be redirected to the new Dashboard.

Kubernetes Cluster (Prometheus)

If everything went well, you’ll be able to see your cluster’s information in the Dashboard.

Conclusion

In this post I’ve shown you how to install both Prometheus and Grafana into a Minikube cluster. You can use the same procedure to do the same in any Kubernetes flavored cluster. I’ve also explained how to deploy one of the grafana.com community dashbaords simply by using its ID.

Hopefully this article will help you get started with Prometheus and Grafana and you’ll soon be able to create your own Dashboards and Panels.

Leave a comment

Your email address will not be published. Required fields are marked *