☁️ Kubernetes Monitoring with Grafana and Prometheus on Huawei Cloud (Manual)

Rabia Yılmaz
Huawei Developers
Published in
5 min readOct 18, 2023
Kubernetes Monitoring with Grafana and Prometheus

Introduction

👋 Hello! I'm happy to give you an introduction to Kubernetes monitoring using Grafana and Prometheus on Huawei Cloud. 🚀

Kubernetes has become one of the most popular container orchestration platforms, providing flexible and scalable solutions for managing containerized applications. Monitoring a Kubernetes cluster is crucial to ensuring the health and performance of your applications and infrastructure.

Prometheus is an open-source monitoring system that specializes in monitoring time series data. It has been widely adopted in the Kubernetes ecosystem due to its scalability and powerful query language.

Grafana is a popular open-source visualization and monitoring tool. It allows you to create dashboards and visually analyze data from various data sources, including Prometheus.

Remember to regularly monitor the performance of your Kubernetes cluster and adjust your monitoring settings as needed. By leveraging the power of Grafana and Prometheus on Huawei Cloud, you can effectively monitor and manage your Kubernetes environment. 🌟

Huawei Cloud Container Engine provides kubernetes monitoring with add-ons. Please click more information for Kubernetes Monitoring on Huawei Cloud Add-Ons.

What is Prometheus?

Prometheus is an open-source monitoring and alerting system. It was developed to monitor the health and performance of systems and applications in a distributed environment. Prometheus collects and stores time series data from various targets such as servers, containers, applications, and services. It uses a pull-based model where measurements are taken at regular intervals from configured endpoints.

Prometheus provides a flexible query language called PromQL that allows users to retrieve and manipulate collected data. It allows the creation of custom dashboards, charts, and alerts to visualize and track metrics. Prometheus also supports alert rules that can be based on predefined conditions and thresholds.

In addition to its core features, Prometheus has a vibrant ecosystem with various exporters and integrations for popular technologies. It integrates well with Grafana, allowing users to create comprehensive monitoring and visualization solutions. 😄

What is Grafana?

Grafana is a popular open-source data visualization and monitoring tool for creating dashboards and graphs to analyze and display metrics from various data sources. It supports many data sources such as databases, time series databases, cloud monitoring services, and more. With Grafana, you can create interactive visualizations, set alerts and notifications, and explore data in real-time. It is widely used in DevOps, system monitoring, and observability to gain insight and make data-driven decisions. 😊

Deploy Prometheus and Grafana on Kubernetes

First of all, we need to connect to the Huawei cloud container engine with the Kube config. If you want to use the K9s tool please follow the documentation. We are using k9s and kubectl. If you want to use those you can follow the article.

Check the cluster with the k9s tool. First, type k9s and press enter.

k9s
K9s vehicle control panel

Install prometheus and grafana.

The GitHub Kubernetes monitoring repository looks like up image
# clone the trace repository on github
git clone https://github.com/scalastic/local-k8s-installation.git

# apply prometheus yaml kubectl apply
k8s/prometheus.yaml
Install Grafana-Prometheus GitHub repo

Metrics Serverserves the goals of core metrics pipelines: CPU and RAM. It's a cluster-level component that periodically scrapes metrics from all Kubernetes nodes served by Kubelet. When installed, Kubernetes Dashboard displays these metrics.

kubectl apply -f k8s/kube-state-metrics-v2.0.0-rc.1.yaml 
kubectl apply -f k8s/metrics-server-components-v0.4.2.yaml
Deploy Metric server on CCE
deploy metric server

Container testing on the terminal with K9s. For details about K9s, go to the article.

Prometheus setup configurations
k9s using on the terminal. Write k9s and click enter. Go to the k9s dashboard
#Grafana setup yaml command
kubectl apply -f k8s/grafana-datasource.yaml
kubectl apply -f k8s/grafana.yaml
Apply grafana data source to Kubernetes
Apply Grafana to Kubernetes
Check all pods on the Huawei Cloud CCE console
Grafana needs the external IP, and up image is network configuration for external access

Test on Huawei Cloud Service

Grafana will be listening on http://localhost:3000. The default login is “admin” / “admin”.

The Grafana login page is Huawei Cloud
Grafana Dashboard (Kubernetes monitoring)

Conclusion

In conclusion, Kubernetes monitoring with Grafana and Prometheus on Huawei Cloud provides a powerful solution for gaining visibility into your Kubernetes cluster and applications. By following the steps outlined in this article, you can set up a comprehensive monitoring stack that allows you to collect metrics, visualize data, and set up alerts.

Prometheus serves as the key component for collecting metrics from various Kubernetes resources, while Grafana enables you to create intuitive dashboards and visualize the collected data. Huawei Cloud provides a reliable infrastructure for hosting your Kubernetes cluster, ensuring scalability and availability.

With this monitoring setup, you can effectively monitor the health and performance of your Kubernetes deployments, identify bottlenecks or anomalies, and make data-driven decisions to optimize resource allocation and improve overall system reliability. Additionally, the ability to set up alerts and notifications allows you to proactively respond to issues and mitigate potential failures before they impact your applications and end-users.

Monitoring your Kubernetes cluster on Huawei Cloud with Grafana and Prometheus empowers you to continuously monitor, analyze, and optimize your infrastructure and applications. By gaining insights into performance trends, resource utilization, and application behavior, you can enhance overall operational efficiency and make informed decisions to deliver an exceptional user experience.

By following these best practices, you can take full advantage of Kubernetes monitoring with Grafana and Prometheus on Huawei Cloud and unlock the potential for efficient and proactive management of your containerized applications. 🌟

I hope this introduction helps you get started with Kubernetes monitoring using Grafana and Prometheus on Huawei Cloud! If you have any more specific questions, feel free to ask.

References

--

--