Goal
Learn how to use Prometheus on OpenShift to collect metrics from an application and then visualize the results with Grafana.
Concepts
- Prometheus, exporters, and application metrics
- Grafana charts and graphs
- OpenShift Web Console
oc
OpenShift command line tool
Use case
You can analyze application metrics to spot problems, monitor performance, audit resource use, and improve your understanding of your application's behavior in order to improve it.
This OpenShift cluster will self-destruct in one hour.
Feedback for this scenario
Did you like this scenario? or Do you think we can improve on something?
You can help us by providing your feedback/suggestions here.
Continue Learning
More information about the applications we used
- Prometheus - A Cloud native application monitoring system.
- Grafana - A data visualization tool with alerting.
How to work with Prometheus Data in Python
Prometheus API Client Python - A Python side client to query metrics data from Prometheus.
We also have created a workshop that will walk you through using the Prometheus API Client:
https://learn.openshift.com/ai-machine-learning/prometheus-api-client/
Time-series forecasting on Prometheus metrics
- We have a workshop that shows how Prometheus metrics can be used for data science applications:
https://learn.openshift.com/ai-machine-learning/prometheus-timeseries-forecasting/
Workshops to learn more about Openshift
- Foundations of OpenShift covers basic OpenShift concepts and common tasks.
- Building Applications on OpenShift has tutorials on using Quarkus, Node.js, Vert.x, etc. on OpenShift.
- Subsystems, Components, and Internals teaches about Linux container internals.
- OpenShift Playgrounds provide an open-ended environment on different OpenShift versions to allow you to experiment and learn on your own.
- Service Mesh Workshop with Istio introduces you to many service mesh concepts.
- Building Operators on OpenShift teaches you about Kubernetes operators, how to build operators on OpenShift, and provides a Kubernetes API refresher if you need it.

Steps
Deploying Prometheus and Grafana on OpenShift
Step 1 - Example of Prometheus metrics being exposed by an application
Playing with the demo application
The demo application is a simulated E-commerce food store application that also exposes some of it's metrics (the food store application might take up to an additional minute to be initialized).
Generating some metrics
The url for the food store is: http://metrics-demo-app-metrics-demo.[[HOST_SUBDOMAIN]]-80-[[KATACODA_HOST]].environments.katacoda.com/
- Once you are able to access the food store application, play around with it, try to buy the products you like [Everything here is free ;) ].
- When you play around with the food store, you make the server serve some requests (GET/POST/..),
some of the metrics for these requests are generated and exposed for Prometheus to collect.
Exposed metrics
The exposed metrics can be found here: http://metrics-demo-app-metrics-demo.[[HOST_SUBDOMAIN]]-80-[[KATACODA_HOST]].environments.katacoda.com/metrics
- This is the endpoint where Prometheus will scrape (collect) metrics from periodically and store them on a persistent storage device like a hard drive (Using OpenShift PersistentVolumes).
- If you don't see similar metrics (pictured above) in your environment, try to make an order with the ecommerce application to generate a few metrics.
You’ll love Katacoda

Guided Path
Knowing what you need to know is the hardest part. Our guided pathways help build your knowledge around real-world scenarios.

Learn By Doing
The best way to learn is by doing. All our tutorials are interactive with pre-configured live environments ready for you to use.

Stay up-to-date
It's a competitive industry. Your skills need to keep up with the latest approaches. Katacoda keeps your skills up-to-date.
You’ll love Katacoda

Guided Path
Knowing what you need to know is the hardest part. Our guided pathways help build your knowledge around real-world scenarios.

Learn By Doing
The best way to learn is by doing. All our tutorials are interactive with pre-configured live environments ready for you to use.

Stay up-to-date
It's a competitive industry. Your skills need to keep up with the latest approaches. Katacoda keeps your skills up-to-date.