Day 16: Getting Started with Prometheus – Monitoring Metrics

Day 16: Getting Started with Prometheus – Monitoring Metrics

Welcome to Day 16 of the Zero to Platform Engineer in 30 Days challenge! ?? Today, we’ll explore Prometheus, the go-to tool for monitoring Kubernetes and collecting real-time metrics.

Why Monitoring with Prometheus?

Monitoring is essential to:

  • Detect Issues Early: Identify problems before they impact users.
  • Optimize Performance: Track CPU, memory, and request latencies.
  • Enable Alerting: Automatically notify teams when issues arise.

?? What Prometheus Provides:

  • Time-series database optimized for Kubernetes metrics.
  • Powerful query language (PromQL) for analyzing data.
  • Built-in alerting and integrations with Grafana, Alertmanager, and more.

Installing Prometheus in Kubernetes

Step 1: Deploy Prometheus with Helm

  1. Add the Prometheus Helm repository:

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

  1. Deploy Prometheus with Helm:

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

  1. Verify that Prometheus is running:

kubectl get pods -n monitoring        

Step 2: Accessing Prometheus UI

  1. Forward Prometheus to your local machine:

kubectl port-forward svc/prometheus-kube-prometheus-prometheus -n monitoring 9090:9090        

  1. Open Prometheus UI in your browser:

?? https://localhost:9090        

Step 3: Querying Metrics with PromQL

Run the following PromQL queries to analyze metrics:

  1. CPU usage of all nodes:

sum(rate(node_cpu_seconds_total[5m])) by (instance)        

  1. Memory usage of all nodes:

sum(container_memory_usage_bytes) by (pod)        

  1. Requests per second to your application:

rate(http_requests_total[1m])        

Activity for Today

  1. Deploy Prometheus using Helm.
  2. Run PromQL queries to analyze your cluster’s metrics.
  3. Configure Alertmanager to notify when CPU usage is high.

What’s Next?

Tomorrow, we’ll visualize Prometheus metrics with Grafana, creating custom dashboards and alerts.

?? Check it out here: Zero to Platform Engineer Repository

Feel free to clone the repo, experiment with the code, and even contribute if you’d like! ??

要查看或添加评论,请登录

Alex Parra的更多文章

社区洞察

其他会员也浏览了