Kubernetes Monitoring with Helm and Prometheus

Helm is the package manager for kubernetes just like apt is for ubuntu

Download helm

curl -o /tmp/get-helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3

Now install helm:

sudo bash /tmp/get-helm.sh

Then add autocompletion:

echo 'source <(helm completion bash)' >> ~/.bashrc
source ~/.bashrc

To add the Prometheus community repository to Helm so its like adding a new software source in Ubuntu we use the below command

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

Just like apt packages up everything needed to run software on Ubuntu, Helm packages up all the YAML, configs, RBAC rules and dependencies needed to run something on Kubernetes.

 helm repo list

Downloads the latest list of available charts from that repo so its similar to apt update

helm repo update

Install prometheus into namespace monitoring

helm install prometheus prometheus-community/prometheus --namespace monitoring --create-namespace

Run the get pods to see the state of pods

kubectl get pods -A

There are five pods here

PodWhat it does
prometheus-serverThe main Prometheus — scrapes and stores metrics
prometheus-alertmanagerSends alerts when thresholds are breached
prometheus-node-exporterCollects host-level metrics — CPU, RAM, disk of the node
prometheus-kube-state-metricsCollects cluster-level metrics — pod states, deployments, replicas
prometheus-pushgatewayAllows batch jobs to push metrics in

Show me all services in every namespace

 kubectl get svc -A
  • awx-serviceNodePort80:30080 that’s why you access AWX on port 30080
  • openclawNodePort18789:30789 — accessible on 30789
  • traefikLoadBalancer — has external IP 172.16.11.121
  • IP prometheus-serverClusterIP — no external access yet

Now edit the prometheus-server service so we can get external access.

kubectl get svc prometheus-server -n monitoring -o yaml > /tmp/prometheus-svc.yaml


Open the file

Change type from cluster port to node port and also expose 30090 for prometheus


Apply the pod config

 kubectl apply -f /tmp/prometheus-svc.yaml

Show me all services in every namespace and port

Then open browser to http://172.16.11.121:30090 and our Prometheus is now ready.

Prometheus Query Language is known as PromQL so we can just run quick querry using up.

Lets check our compute on our AWX namespace by running

  • container_memory_usage_bytes{namespace=”awx”}
  • container_cpu_usage_seconds_total{namespace=”awx”}

That shows the usage of my AWX pods

(Visited 2 times, 1 visits today)

By Ash Thomas

Ash Thomas is a seasoned IT professional with extensive experience as a technical expert, complemented by a keen interest in blockchain technology.