Kubernetes Prometheus (original) (raw)

Last Updated : 23 Jul, 2025

With modern DevOps becoming more and more complex, monitoring and alerting stakeholders has become even more crucial for any microservice, and Prometheus is a tool to do the same. Prometheus is a completely open-sourced tool created to monitor highly dynamic container environments like Kubernetes, Docker Swarm, etc. However, it can also be used in a traditional non-container infrastructure where you have just bare servers with applications deployed directly on them. In this article, we will learn what prometheus is. We will see why Prometheus is so important in such infrastructure. And what are some of its use cases?

Table of Content

What is Prometheus Monitoring?

Prometheus is a tool created to monitor highly dynamic container environments like Kubernetes, Docker Swarm, etc.; however, it can also be used in a traditional non-container infrastructure where you have just bare servers with applications deployed directly on them. Prometheus provides a monitoring and alerting toolkit designed especially for microservices and containers. Over the past years, Prometheus has become the mainstream monitoring tool of choice in the container and microservice worlds. Prometheus is a Cloud Native Computing Foundation (CNCF) graduate project that was released in July 2016.

Why use Prometheus for Kubernetes monitoring?

Prometheus Architecture

Prometheus Architecture at its core has the main component called Prometheus server that does the actual monitoring work and is made up of three parts:

prometheus-1

Key Terminologies

Tutorial - Deploying Prometheus Monitoring in Kubernetes Cluster

There are three ways to deploy Prometheus in a Kubernetes Cluster:

In this tutorial we will deploy Prometheus in a local Kubernetes Cluster using the third method which is using Helm chart to deploy the Prometheus Operator. This helm chart that is maintained by the helm community itself and is the most efficient and hassle free way of using Prometheus in any Cluster. In this demo, Helm will do the initial setup and Operator will then manage the running Prometheus setup.

**Step 1: Creating a Kubernetes Cluster

You can skip this step if you already have a Kubernetes Cluster running in your machine. But in case you don't have a Cluster running enter the following command to create Kubernetes locally using Minikube:

minikube start

Minikube

Minikube is a one-node Kubernetes cluster where master processes and work processes both run on one node.

**Step 2: Installing Helm

You can install Helm if haven't already. For Ubuntu, run the following script in order to

curl https://baltocdn.com/helm/signing.asc | gpg --dearmor | sudo tee /usr/share/keyrings/helm.gpg > /dev/null
sudo apt-get install apt-transport-https --yes
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/helm.gpg] https://baltocdn.com/helm/stable/debian/ all main" | sudo tee /etc/apt/sources.list.d/helm-stable-debian.list
sudo apt-get update
sudo apt-get install helm

**Step 3: Adding the Prometheus repository

Let's start with adding the Prometheus repository using by entering the following command:

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

And then update the repository by entering the following command:

helm repo update

Following message with appear if the Prometheus repository is added via Helm and updated.

helm repo

**Step 4: Installing Prometheus

Enter the following command to install Prometheus using default values:

helm install prometheus prometheus-community/prometheus

You will get a similar output and Prometheus will be installed in the Cluster.

Prometheus

**Step 5: Checking all the resources installed

Now that Prometheus is installed in our cluster, we can check all the resources that were installed by the following command:

kubectl get all

And this will give you the list of all the deployed Kubernetes resources:

pods

**Step 6: Expose the "prometheus-server" Service

Now that Prometheus is installed in your cluster, we can you it to monitor our cluster. In order to open the Prometheus dashboard on our browser, we need to expose the "prometheus-server" Service since it is currently set as a ClusterIP.

kubectl expose service prometheus-server --type=NodePort --target-port=9090 --name=prometheus-server-ext

This will expose "prometheus-server" Service to port 9090. It check it in our browser, enter the following command, this command will generate the URL for our Prometheus application.

minikube service prometheus-server-ext

And you will get the following dashboard ready:

Prometheus UI

And with that we have successfully installed Prometheus on our local Kubernetes Cluster using Helm. Prometheus is running inside the cluster and we can access it using a browser/URL.

Advantages of Prometheus

Advantages of Prometheus compared to other Monitoring tools are listed as following:

Prometheus is a widely used monitoring tool in Kubernetes environments, but it's not the only option available. Here's a comparison of Prometheus with other popular Kubernetes monitoring tools:

1. **Prometheus

**Pros:

**Cons:

The challenges of Prometheus scaling and monitoring

Monitoring and scaling There are quite some problems with Prometheus, a popular open-source monitoring and alerting arsenal. What follows highlights some of the major issues along with potential solutions for each:

  1. **High Cardinality Metrics
    • **Challenge: Prometheus can grow slow and consume a lot of memory if there have too many different metric labels.
    • **Solution: Avoid using too many labels or various versions of it. Use caution while giving labels, and remove the ones that don't seem necessary. If required, split data between multiple Prometheus instances.
  2. **Storage Limits
    • **Challenge: Massive amounts of long-term data aren't suitable for Prometheus' built-in storage.
    • **Solution: For long-term, scalable storage, use external systems like VictoriaMetrics, Cortex, or Thanos. Better data the preservation and scaling beyond what Prometheus naturally provides can be made feasible by these platforms.
  3. **Slow Queries and High Resource Usage
    • **Challenge: Searches could grow slow in large datasets, and Prometheus can use a lot of CPU and memory, especially if there are many targets or regular scrapes.
    • **Solution: To enhance the response times, optimize your queries while taking advantage of caching methods. To balance resource use and performance, adjust the timeouts and scrape intervals. For optimum velocity, use a lot Prometheus servers to distribute the load and consider using an external query engine like Thanos Querier.

Increased management overhead for SREs and platform teams

Managing and scaling Due to the challenges with controlling alert fatigue, troubleshooting, and maintaining numerous times, Prometheus adds to the management cost for SREs and platform teams. Hand work can be substantially decreased by automating configuration and management using software like infrastructure-as-code solutions and Kubernetes Operators. Prometheus Alertmanager's intelligent alerting methods can be used to prioritize significant issues while decreasing noise. Proactive detection of monitoring systemic issues is ensured via establishing meta-monitoring with a secondary Prometheus instance. When combined, these approaches improve operational efficiency and reduce the extra load on platform teams and SREs.

Prometheus Kubernetes Service Discovery

Conclusion

Over the past years Prometheus has become the mainstream monitoring tool of choice in container and micro service world. Prometheus while is a tool created to monitor highly dynamic container environments like Kubernetes, Docker Swarm etc. it can also be used in a traditional non container infrastructure where you have just bare servers with applications deployed directly on them. Make sure to follow all the points we mentioned in the article and well as perform the tutorial yourself for better understanding of the tool.