How to use Helm to integrate Prometheus and Grafana Part 1 on K8s

Mondo Technology Updated on 2024-01-30

In this three-part series, you'll learn how Xi integrate Prometheus and Grafana on Kubernetes using Helm, and how to create a simple dashboard on Grafana. Prometheus and Grafana are two of the most popular open-source monitoring tools for Kubernetes. Learn how Xi use Helm to integrate these two tools, making it easy for you to monitor and troubleshoot your Kubernetes clusters。You'll also get a deeper understanding of the health and performance of your cluster, which will track resources and performance metrics on your Kubernetes cluster.

As mentioned earlier, Prometheus and Grafana are popular tools for monitoring container orchestration platforms. Two of the most popular container orchestration tools are Docker Swarm and Kubernetes. The first part will introduce you to the prerequisites for using Prometheus and Grafana, and understand what Prometheus and Grafana are.

To keep up with this guide, you'll need to:

Install docker: To install docker on your machine, check out the official docker documentation

Install kubectl: This allows you to communicate with the Kubernetes cluster. To install the Kubectl tool on your local machine, follow the official Kubectl documentation guidelines

Basic knowledge of Kubernetes: Make sure you have some understanding of Kubernetes. You can learn Xi more about K8S by reading the official Kubernetes documentation.

Set up a Kubernetes cluster: Install Prometheus and Grafana on the Kubernetes cluster. This guide will use minikube (a quick guide This is a free on-premises Kubernetes cluster.

Prometheus is an open-source DevOps tool. It provides monitoring and real-time alerting capabilities for container orchestration platforms such as Kubernetes, collecting and storing metrics from the platform in the form of time-series data. Second, it has the out-of-the-box capabilities to monitor container orchestration platforms and is a data source for other data visualization libraries like Grafana.

The metrics that Prometheus collects from Kubernetes clusters include:

Kubernetes cluster health.

CPU status.

Memory usage.

Kubernetes node status.

Potential performance bottleneck reports.

Performance metrics. Server resources.

Grafana is a multi-platform, open-source** application for analytics and interactive visualization. When you connect it to a supported data source, such as Prometheus, it provides:

Interactive control panel.

Interactive charts.

Visualizations.

Network alerts. No matter what the data source is, Grafana can query, visualize, and understand your metrics for you. In addition to Prometheus, Grafana supports several other data sources, such as:

influxdb

azuremonitor

datadog

graphite

aws cloudwatch。

postgresql

microsoft sql server (mssql)。

elasticsearch

google cloud monitoring

mysqlalertmanager

Loki has the option to create a dashboard from scratch, or import a dashboard that Grafana already provides and customize it to suit your needs. Most DevOps professionals use Grafana and Prometheus to create powerful time series databases with data visualization dashboards.

Here, we'll create a dashboard for visualizing the metrics collected from the Prometheus data source.

The following diagram shows the components of Prometheus and how it works

These are all components of Prometheus:

prometheus serveris a core component of the Prometheus architecture. It is where the actual monitoring work takes place.

alertmanagerSend alerts to users via email and other communication channels such as Slack.

pushgatewayAd-hoc tasks can be supported. It allows users to push time series data to Prometheus targets. It also handles metrics for short-term tasks.

The Prometheus server can be further divided into three components:

data retrieval workerScrape and collect metrics from a container orchestration platform. It then converts the metric into time series data. It collects metrics from a number of indicators, which are specified in their settings.

time series databaseStores time series data from the data retrieval component.

http serverRespond to requests and promql queries for time series data. It then displays the information on a web user interface or dashboard. It can use both third-party platforms like Grafana and the built-in Prometheus Web UI.

Setting up Prometheus and Grafana for monitoring gives us a lot of benefits:

You get a complete end-to-end solution for observing and monitoring Kubernetes clusters.

You can query metrics using the Prometheus PromQL query language.

If you have a microservices architecture, Prometheus keeps track of all your microservices at the same time.

When a service fails, an alert is issued immediately.

The Grafana dashboard provides performance and health reports for your cluster.

When it comes to integrating Prometheus and Grafana on Kubernetes, developers generally take two approaches:

Manual Kubernetes deployment: In this approach, developers need to write Kubernetes deployment and service yaml files. YAML needs to be written for Prometheus and Grafana applications. In the yaml file, specify all the configurations for integrating Prometheus and Grafana on Kubernetes. Then, deploy these files to the Kubernetes cluster so that Prometheus and Grafana work properly. The downside of this approach is that developers can have a lot of YAML files, which can be annoying for most DevOps practitioners. If you get it wrong in any of the yaml files, you won't be able to integrate Prometheus and Grafana on Kubernetes.

Use helm: This is the deployment of the application container to KubernetesThe easiest and easiest way to do it。Helm is the official package manager for Kubernetes. With Helm, you can simplify the installation, deployment, and management of your Kubernetes applications. Helm packages the Kubernetes application into a Helm chart.

The helm chart is a collection of all the yaml files:

Deployment

services

Keys

configmaps manifests

You'll use these files to deploy your application containers to Kubernetes. Helm allows users to have a Helm Chart with a manifest YAML file instead of creating a separate YAML file for each application container.

Related Pages