A logo showing the text blog.marcnuri.com
Español
Home»Operations»Prometheus and Grafana setup in Minikube

Recent Posts

  • Fabric8 Kubernetes Client 6.5.0 is now available!
  • Eclipse JKube 1.11 is now available!
  • Fabric8 Kubernetes Client 6.4.1 is now available!
  • I bought an iPad
  • Three years at Red Hat

Categories

  • Front-end
  • Java
  • JavaScript
  • Legacy
  • Operations
  • Personal
  • Pet projects
  • Tools

Archives

  • March 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022
  • August 2022
  • July 2022
  • June 2022
  • May 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • January 2021
  • December 2020
  • November 2020
  • October 2020
  • September 2020
  • August 2020
  • July 2020
  • June 2020
  • May 2020
  • December 2019
  • October 2019
  • September 2019
  • July 2019
  • March 2019
  • November 2018
  • July 2018
  • June 2018
  • May 2018
  • April 2018
  • March 2018
  • February 2018
  • December 2017
  • July 2017
  • December 2015
  • November 2015
  • November 2008
  • November 2007
  • September 2007
  • August 2007
  • July 2007
  • June 2007
  • May 2007
  • April 2007
  • March 2007

Prometheus and Grafana setup in Minikube

2020-10-13 in Operations tagged Grafana / Helm / Kubernetes / Metrics / Monitoring / Prometheus by Marc Nuri | Last updated: 2021-07-02
Versión en Español

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:

1helm repo add prometheus-community https://prometheus-community.github.io/helm-charts

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

1helm install prometheus prometheus-community/prometheus
2kubectl expose service prometheus-server --type=NodePort --target-port=9090 --name=prometheus-server-np

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

1minikube service prometheus-server-np
Prometheus Web Interface in Minikube
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:

1helm repo add grafana https://grafana.github.io/helm-charts

Next, we install Grafana by using the provided charts:

1helm install grafana stable/grafana
2kubectl expose service grafana --type=NodePort --target-port=3000 --name=grafana-np

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:

1kubectl get secret --namespace default grafana -o jsonpath="{.data.admin-password}" | base64 --decode ; echo

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

1minikube service grafana-np
Grafana Login Web Interface in Minikube
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
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 click Load.

Grafana Import Dashboard from grafana.com
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
Grafana import dashboard - configure Datasource

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

Kubernetes Cluster (Prometheus)
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 dashboards 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.

If you’re interested in dashboards and other ways to visualize your Kubernetes cluster resources, be sure to check out YAKC – Kubernetes Dashboard.

Twitter iconFacebook iconLinkedIn iconPinterest iconEmail icon

Comments in "Prometheus and Grafana setup in Minikube"

  • Avatar for Guy Cole
    Guy Cole
    2021-02-10 04:02
    Thank you for the clear post w/working examples and nice screenshots.
  • Avatar for SUJIT GANGADHARAN
    SUJIT GANGADHARAN
    2021-05-09 17:25
    Thank you for this setup instructions. Really helpful.

Post navigation

← Eclipse JKube introduction: Java tools and plugins for Kubernetes and OpenShiftRollout Restart Kubernetes Deployment from Java using YAKC →
© 2007 - 2023 Marc Nuri