Image Source

Monitoring ensures the availability of an application and verifies that it meets the service level agreement in any DevOps project. Monitoring starts with provisioning and exposing information from the relevant application. Then you need to continuously overview the state of the application and gather metrics of the underlying infrastructure.

Prometheus is an open source monitoring system. Prometheus is well suited for complex workloads, thanks to its ability to process large amounts of data every second. One of the main benefits of Prometheus is the simple text-based metrics format. 

Another advantage of Prometheus is an extensive list of supported products, including Kubernetes, databases, server applications, and Java Virtual Machines (JVM). In this article, you will learn how to monitor Kubernetes with Promoetheus, which is the default monitoring option in Kubernetes.

Why Prometheus Is the Right Tool for Kubernetes Monitoring

Kubernetes and container-based infrastructures utilize a huge number of services, virtual network addresses, and metrics. These tasks generate a  lot of data, which can be overwhelming for traditional monitoring tools. Prometheus benefits include:

  • Data model—Prometheus and Kubernetes have a similar model for storing data. Prometheus stores data as time series. The data is stored as streams of timestamped values belonging to the same metric. Kubernetes organizes infrastructure metadata in a similar way. This similarity enables you to get more flexible and accurate data.
  • Accessible format and protocols—metrics in Prometheus are in a self-explanatory and human readable format. You can check that the metrics are correctly exposed by using a web browser since they are published in standard HTTP.
  • Service discovery—the Prometheus server automatically pulls metrics from monitored applications and services. The auto-discovery model is a good fit for ephemeral Kubernetes workloads because the targets are periodically scraped by the server.

How Prometheus Monitoring Works in Kubernetes

Prometheus pulls data from Kubernetes services by sending an HTTP request called scrape. The response to scrape is stored in a custom database on the Prometheus server along with the metrics for the scrape itself. 

Prometheus then needs to access the stored data and collect different Kubernetes metrics:

  • Machine-level metrics—Prometheus can access machine-level metrics like CPU, memory, and networks by using node exporters. Exporters ensure that the metrics are in a supported format, and expose the requested data to the Prometheus server.
  • Cluster metrics—Prometheus collects cluster metrics like pod, deployments, resource, and reservation by using Kube-state-metrics.
  • Internal metrics—internal Kubernetes components like etcd, kubelet, scheduler, and dns are responsible for exposing internal system metrics

Developers can access the collected data by using the PromQL query language. These metrics are visualized on graphical interfaces like Grafana, or use it to send alerts with the Alertmanager.

Installing Prometheus on Kubernetes

You can configure Prometheus monitoring by using YAML (Yet Another Markup Language) files. YAML files contain permissions, configurations, and services. Prometheus uses these files to access resources and pull information by scraping Kubernetes cluster elements. YAML files are available on GitHub.

After configuration is done, you can install Prometheus as a Docker container in a Kubernetes cluster. These Docker containers can have different orchestration options like StatefulSets, Kubernetes operators, Docker containers, Helm package manager, and Kubernetes operators. 

To deploy the Prometheus server inside a container use the following command in the Prometheus user interface

docker run -p 9090:9090 -v /tmp/configuration.yml:/etc/prometheus/configuration.yml  prom/prometheus

Another option is to change the Docker container into a Kubernetes deployment object. This deployment object will mount the configuration from a ConfigMap.

kubectl create configmap prometheus-example-cm --from-file configuration.yml

Monitoring Kubernetes Services with Prometheus

Services like Istio, and Traefik web proxy can collect Prometheus metrics by default. You need to use an exporter to monitor other services. 

Monitoring the Traefik service

Traefik is a reverse proxy that integrates with containers and microservices. You can use Traefik as an Entrypoint or an Ingress controller. Traefik is the connection point between the microservices inside a cluster and the external network.

Deploy Traefik with Prometheus using the following command:

kubectl create -f

Add the new monitoring target to the YAML configuration file

 - job_name: 'prometheus'

    # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'.

    - targets: ['localhost:9090']

Monitor Kubernetes services using Prometheus exporters

A Prometheus exporter is a kind of adapter that converts main service metric formats to Prometheus metrics format.

Deploy a pod that contains the Prometheus sidecar and the Redis server using the following command:

kubectl create -f prometheus-monitoring/prometheus_redis_exporter.yaml

Update the Prometheus YAML configuration file and reload

 - job_name: 'redis'
      - targets: ['redis:9121']

Monitoring of a Kubernetes cluster

The Kubernetes cluster internal monitoring process consists of the following components:

  • cAdvisor—an open source agent that aggregates, processes, and exports information on container performance and resource usage. cAdvisor is a part of the Kubelet binary in Kubernetes.
  • Kube-state-metrics—a service that monitors the Kubernetes API server and produces metrics about the object state, deployments, pods and nodes.
  • Metrics-server—aggregates resource usage data across the entire cluster. Metrics-server is focused on implementing resource metrics like CPU, memory, file descriptors and more.

To monitor kube-state-metrics with Prometheus you have to scrape the service port in the Prometheus configuration file:

- job_name: 'kube-state-metrics'
    - targets: ['kube-state-metrics.kube-system.svc.cluster.local:8080']

Another option is to use Helm charts. To install the chart use the following code snippet for Helm 2:

helm init --service-account tiller
helm install --name node-exporter stable/prometheus-node-exporter

After you have installed and configured the scrape file, you can collect and display the node metrics.

Using Prometheus to monitor Kubernetes internal components

Some Kubernetes components like kube-scheduler, etcd, or kube-controller can expose Kubernetes’s internal performance metrics when using Prometheus.

You can monitor internal components in the same way you monitor any other Prometheus endpoint. There are just two exceptions to this option:

  • Network interfaces for listening—your deployment method and configuration templates depend on the http scheme and security services like RBAC. These services are difficult to reach from the Prometheus pods because they are only listening at localhost in the hosting node.
  • Kubernetes service pointing to the pods—some Kubernetes components may not have a service pointing to the pods.


This tutorial explains how to collect and monitor metrics with Prometheus on Kubernetes. Monitoring enables you to achieve more transparency and get insight on your Kubernetes application. In addition, monitoring ensures the health, performance, and behavior of your system. Proactive monitoring should be an integral part of your application development process.

Products like Opvizor Performance Analyzer provide all these monitoring capabilities out of the box. If you run Kubernetes on top of VMware vSphere, you get a 360 degree view. And stay tuned for the pure Kubernetes edition.


Guest Author Bio

Image source

Gilad David Maayan is a technology writer who has worked with over 150 technology companies including SAP, Samsung NEXT, NetApp and Imperva, producing technical and thought leadership content that elucidates technical solutions for developers and IT leadership.


Metrics and Logs

(formerly, Opvizor Performance Analyzer)

VMware vSphere & Cloud

Monitor and Analyze Performance and Log files:
Performance monitoring for your systems and applications with log analysis (tamperproof using immudb) and license compliance (RedHat, Oracle, SAP and more) in one virtual appliance!

Subscribe to Our Newsletter

Get the latest product updates, company news, and special offers delivered right to your inbox.

Subscribe to our newsletter

Use Case - Tamper-resistant Clinical Trials


Blockchain PoCs were unsuccessful due to complexity and lack of developers.

Still the goal of data immutability as well as client verification is a crucial. Furthermore, the system needs to be easy to use and operate (allowing backup, maintenance windows aso.).


immudb is running in different datacenters across the globe. All clinical trial information is stored in immudb either as transactions or the pdf documents as a whole.

Having that single source of truth with versioned, timestamped, and cryptographically verifiable records, enables a whole new way of transparency and trust.

Use Case - Finance


Store the source data, the decision and the rule base for financial support from governments timestamped, verifiable.

A very important functionality is the ability to compare the historic decision (based on the past rulebase) with the rulebase at a different date. Fully cryptographic verifiable Time Travel queries are required to be able to achieve that comparison.


While the source data, rulebase and the documented decision are stored in verifiable Blobs in immudb, the transaction is stored using the relational layer of immudb.

That allows the use of immudb’s time travel capabilities to retrieve verified historic data and recalculate with the most recent rulebase.

Use Case - eCommerce and NFT marketplace


No matter if it’s an eCommerce platform or NFT marketplace, the goals are similar:

  • High amount of transactions (potentially millions a second)
  • Ability to read and write multiple records within one transaction
  • prevent overwrite or updates on transactions
  • comply with regulations (PCI, GDPR, …)


immudb is typically scaled out using Hyperscaler (i. e. AWS, Google Cloud, Microsoft Azure) distributed across the Globe. Auditors are also distributed to track the verification proof over time. Additionally, the shop or marketplace applications store immudb cryptographic state information. That high level of integrity and tamper-evidence while maintaining a very high transaction speed is key for companies to chose immudb.

Use Case - IoT Sensor Data


IoT sensor data received by devices collecting environment data needs to be stored locally in a cryptographically verifiable manner until the data is transferred to a central datacenter. The data integrity needs to be verifiable at any given point in time and while in transit.


immudb runs embedded on the IoT device itself and is consistently audited by external probes. The data transfer to audit is minimal and works even with minimum bandwidth and unreliable connections.

Whenever the IoT devices are connected to a high bandwidth, the data transfer happens to a data center (large immudb deployment) and the source and destination date integrity is fully verified.

Use Case - DevOps Evidence


CI/CD and application build logs need to be stored auditable and tamper-evident.
A very high Performance is required as the system should not slow down any build process.
Scalability is key as billions of artifacts are expected within the next years.
Next to a possibility of integrity validation, data needs to be retrievable by pipeline job id or digital asset checksum.


As part of the CI/CD audit functionality, data is stored within immudb using the Key/Value functionality. Key is either the CI/CD job id (i. e. Jenkins or GitLab) or the checksum of the resulting build or container image.

White Paper — Registration

We will also send you the research paper
via email.

CodeNotary — Webinar

White Paper — Registration

Please let us know where we can send the whitepaper on CodeNotary Trusted Software Supply Chain. 

Become a partner

Start Your Trial

Please enter contact information to receive an email with the virtual appliance download instructions.

Start Free Trial

Please enter contact information to receive an email with the free trial details.