Tech Blog

Coding

Deploying Prometheus and Grafana using Helm in kubernetes

By Sai Nandhan3 min read
← Back to blog

Hi Everyone!! If you have deployed any application using kubernetes, it is very important to monitor the kubernetes cluster and the application. ‘Monitoring’ plays a crucial role. For monitoring purposes, the popular and widely used tools are prometheus and grafana. They are often used together. Prometheus is used to store the metrics and grafana is a visualization tool.

Prerequisites:

1) Fully functional kubernetes cluster
2) ‘helm’ Command line tool

Steps to deploy Prometheus:

Step1:- create a namespace named ‘prometheus’. Run the following command

kubectl create namespace prometheus

Step2: In helm, there is already a chart named ‘prometheus-community’ which we can use directly to deploy prometheus. To add the ‘prometheus-community’ chart repository. Run the following command.

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

Step 3: Deploy Prometheus by running the following command.

helm upgrade -i prometheus prometheus-community/prometheus –namespace prometheus

This command uses the chart ‘prometheus-community’ and installs all prometheus related components in the namespace ‘prometheus’. By default, all default values are used. However, if needed, you can override the values using the ‘–set’ flag.

Once it is done, You can verify if all of the pods in the ‘prometheus’ namespace are in the ‘READY’ state. To check it, Run the command.

kubectl get pods -n Prometheus

Steps to deploy grafana dashboard:

1)Create a namespace named ‘grafana’ by running the following command.

kubectl create namespace grafana

2)Add a grafana repository using helm by running the following command.

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

3)To deploy grafana, run the following command.

helm install grafana grafana/grafana  –namespace grafana   –set persistence.enabled=true  –set adminPassword=’EKS!sAWSome’ –set datasources.”datasources\.yaml”.apiVersion=1   –set datasources.”datasources\.yaml”.datasources[0].name=Prometheus  –set datasources.”datasources\.yaml”.datasources[0].type=prometheus    –set datasources.”datasources\.yaml”.datasources[0].url=http://prometheus-server.prometheus.svc.cluster.local     –set datasources.”datasources\.yaml”.datasources[0].access=proxy     –set datasources.”datasources\.yaml”.datasources[0].isDefault=true 

This command installs all grafana related components and overrides few default values. Make sure to check the value of ‘datasources[0].url’ which is the url of the ‘prometheus’. ‘adminPassword’ is the password we want to use to login to the grafana dashboard.

Once the above command is run, you can run the following command to verify all the resources in grafana.

kubectl get all -n grafana

When you list the resources, you can find one external-ip for a service named ‘grafana’. Through that url, you can access the grafana dashboard.

If you follow all these steps properly, You will be able to install prometheus and grafana and access the grafana dashboard.

I hope you enjoyed the article. Thanks for reading!!

Keep reading

You may be interested in

Browse all articles →
Active Directory Federation Service
July 5, 20235 min read

Active Directory Federation Service

Active Directory Federation Service (ADFS) uses claims-based identity model to maintain application security and to implement federated identity. ADFS is a concept of Windows Server operating system, that provides users with single sign-on access to the application, those are located across organizational boundaries. For Example: We have 2 organizations – Organization 1 and Organization 2. […]

By Abinash MishraRead More →
Remote Access to Microsoft SQL Database Server
April 5, 20232 min read

Remote Access to Microsoft SQL Database Server

Remote access to a SQL server is important because it allows users to access the server from anywhere, at any time. This enables remote workers to access the data they need when they need it, even if they are not physically in the same location as the server. It also allows IT admins to access […]

By Malkeet SinghRead More →
Types of Load Balancer in AWS
February 6, 20235 min read

Types of Load Balancer in AWS

What is Load Balancing ? Load balancing is a critical component of any scalable and highly available Cloud or On-premise architecture. It helps distribute incoming traffic across multiple servers, improving the availability and scalability of a website or application. In the cloud, load balancing is offered as a service by various cloud providers such as […]

By Keerthik ShenoyRead More →