Prometheus Kubernetes lets you analyze software and infrastructure performance by gathering and saving detailed system metrics almost in real-time.
It is often used on Kubernetes to track CPU performance, memory usage, network traffic, the status of Kubernetes pods, and more.
What is Prometheus Kubernetes?
Prometheus Kubernetes is a free platform that collects, stores, and visualizes time-series metrics. It enables in-depth analysis, data correlation and provides valuable insights into system performance. Its flexible PromQL and ability to handle large data volumes make it ideal for monitoring complex environments.
Kubernetes Prometheus is a server that uses a pull-based system to send HTTP requests, which creates scrapes. The responses are saved in a repository on a server that can manage large volumes of data. Exporters, which are software components located next to the application, enable Prometheus to retrieve data that the application does not control, such as kernel metrics.
Reasons to choose Prometheus for Kubernetes monitoring:
- Built-in support for K8s service discovery: it automatically finds and monitors new services and pods as they are deployed and scaled within the K8s cluster.
- Rich data model: it allows detailed categorization and querying of metrics based on various attributes like pod labels, namespace, service name, etc.
- Integration with visualization tools: it works well with Grafana, allowing users to create custom dashboards and visualizations for better insights into K8s metrics.
- Scalability and performance: It can manage large data using fewer resources, making it perfect for Kubernetes.
- Proven reliability: many organizations of all sizes use it for monitoring Kubernetes environments, effectively handling the constantly changing status of K8s.
- Community support: both Prometheus and Kubernetes are part of CNCF, which has a large community along with extensive documentation and tutorials.
- Open-source: Being open-source, Prometheus is a flexible option for monitoring Kubernetes.
Prometheus Kubernetes Metrics Overview (Metrics It Provides)
Get exclusive access to all things tech-savvy, and be the first to receive
the latest updates directly in your inbox.
- Counter: Best for measuring the start of events or counting the total number of events.
- Gauge: Tracks changes in both negative and positive directions, perfect for point-in-time measurements.
- Histogram: Collects and categorizes events while providing a total sum of observed values, great for data aggregation.
- Summary: Works with histogram metrics and computes quantiles over a moving time window, producing an accurate range of quantiles.
Prerequisites Before Installation
Step 1: Set up a Kubernetes cluster
Install Kubernetes on your machine or opt for a managed Kubernetes service such as Google Kubernetes Engine (GKE), Amazon Elastic Kubernetes Service (EKS), or Azure Kubernetes Service (AKS).
Step 2: Create a namespace
Open your terminal or command prompt and execute the following command to create a namespace for Prometheus:
kubectl create namespace prometheus
Step 3: Create a Prometheus configuration file
Create a file called prometheus-config.yaml and open it.
You can insert the following YAML configuration into the file:
apiVersion: v1<br>kind: ConfigMap<br>metadata:<br>name: prometheus-server-conf<br>namespace: prometheus<br>data:<br>prometheus.yml: |<br>global:<br>scrape_interval: 15s<br>evaluation_interval: 15s<br>scrape_configs:<br>- job_name: 'prometheus'<br>static_configs:<br>- targets: ['localhost:9090']
Step 4: Apply the Prometheus configuration
Run the following command to apply the Kubernetes Prometheus configuration:
kubectl apply -f prometheus-config.yaml -n prometheus
Step 5: Create a Prometheus deployment
Create a file named prometheus-deployment.yaml and open it. Then just add this YAML configuration to the file:
apiVersion: apps/v1<br>kind: Deployment<br>metadata:<br>name: prometheus-server<br>namespace: prometheus<br>spec:<br>replicas: 1<br>selector:<br>matchLabels:<br>app: prometheus-server<br>template:<br>metadata:<br>labels:<br>app: prometheus-server<br>spec:<br>containers:<br>- name: prometheus<br>image: prom/prometheus<br>ports:<br>- containerPort: 9090<br>volumeMounts:<br>- name: config-volume<br>mountPath: /etc/prometheus<br>volumes:<br>- name: config-volume<br>configMap:<br>name: prometheus-server-conf<br>defaultMode: 420
Step 6: Apply the Prometheus deployment
Run the following command to apply the Prometheus deployment:
kubectl apply -f prometheus-deployment.
Step 7: Set up Prometheus as a service
Create a file called prometheus-service.yaml and open it.
Add this YAML configuration to the file:
apiVersion: v1<br>kind: Service<br>metadata:<br>name: prometheus-service<br>namespace: prometheus<br>spec:<br>selector:<br>app: prometheus-server<br>ports:<br>- protocol: TCP<br>port: 80<br>targetPort: 9090<br>type: LoadBalancer
Step 8: Implement the Prometheus service
Execute this command to implement the Prometheus service:
kubectl apply -f prometheus-service.yaml -n prometheus
Step 9: Access Prometheus
Run this command to retrieve the external IP address of the Prometheus service:
kubectl get service prometheus-service -n prometheus
How to Monitor Kubernetes Service with Prometheus
Prometheus automates monitoring by sending alerts when metrics do not meet expectations, like spikes in memory usage. The Alertmanager notification system can send messages to various receivers, including email, Slack, messaging apps, and webhooks, to ensure prompt action.

This is optional! Just use this command ensure that all the relevant elements run properly in the monitoring namespace:
kubectl get all -n monitoring
Verify that all of the Pods in the Prometheus
Kubernetes namespaces are in the READY
state.
<code>kubectl get pods -n prometheus</code>
An example output is as follows
<code>NAME READY STATUS RESTARTS AGE prometheus-alertmanager-59b4c8c744-r7bgp 1/2 Running 0 48s prometheus-kube-state-metrics-7cfd87cf99-jkz2f 1/1 Running 0 48s prometheus-node-exporter-jcjqz 1/1 Running 0 48s prometheus-node-exporter-jxv2h 1/1 Running 0 48s prometheus-node-exporter-vbdks 1/1 Running 0 48s prometheus-pushgateway-76c444b68c-82tnw 1/1 Running 0 48s prometheus-server-775957f748-mmht9 1/2 Running 0 48s</code>
Summary Of Steps
Now you can be confident that setting up Prometheus Kubernetes wasn’t that hard. If you’re really into it, you can do it very efficiently.
Keeping an eye on things is super important, whether you’re testing stuff out or running a production cluster. Prometheus Kubernetes monitoring paired with Grafana is a game-changer for us. It really simplifies our work with its customizable interface and configurable exporters. Plus, it’s open-source! That said, K8s does have its own official dashboard, and honestly, Prometheus + Grafana just can’t compete with that.
FAQ’s
1. What is Prometheus in Kubernetes?
Prometheus is an open-source monitoring and alerting toolkit widely used in Kubernetes environments. It collects metrics, stores them in a time-series database, and allows users to visualize cluster health and performance.
2. Can Prometheus monitor multiple Kubernetes clusters?
Yes. Using federation or a central setup, Prometheus can track metrics across multiple clusters.
3. How many resources does Prometheus consume in Kubernetes?
It varies. Small setups may need under 2GB RAM, while large clusters may require much more.
4. Is Prometheus better than other monitoring tools for Kubernetes?
Prometheus is Kubernetes-native, open-source, and lightweight—making it a top choice over many alternatives.
5. Do I need Grafana with Prometheus?
Not required, but Grafana adds powerful dashboards for better visualization and insights.
6. Can Prometheus be used in production Kubernetes clusters?
Yes. But only with proper configuration, Prometheus is reliable for production workloads.