Creating and deploying application on top of Openshift is one thing, but doing health monitoring for those applications is a whole new different thing. Thats why on this session im trying to share on how to deploy Prometheus, for monitoring appliction statistics, and Grafana, for visualizing it, to support the day-to-day activity and operations.
So before started too far, lets start with a brief introduction on what is Prometheus and Grafana.
According to its site (https://prometheus.io/), Prometheus is an open-source systems monitoring and alerting toolkit. It has multiple visualization tools and Grafana as one of it. On Grafana’s website, https://grafana.com/, we can see that it is an open source visualization and analytics software, which allows us to query, visualize, alerting and explore our metrics freely.
Okay, there are multiple ways of installing those two items. One way is by using Openshift Operator, and another way is installed it manually either by using template, or a simple container image installation. For this time, we are using the last approach, and that is container image deployment.
for this example, im using openshift/prometheus image from docker hub.
Once image has been created, next is creating a configuration file for storing list of prometheus api needed to be scrape from, for this example im scrapping statistics from application App01 which located on project Project01 on top of the same OCP4 instance.
global: scrape_interval: 15s scrape_timeout: 10s evaluation_interval: 15s alerting: alertmanagers: - static_configs: - targets:  scheme: http timeout: 10s scrape_configs: - job_name: project01 scrape_interval: 15s scrape_timeout: 10s metrics_path: /metrics scheme: http static_configs: - targets: - app01.project01.svc.cluster.local:8080 basic_auth: username: dev01 password: password
Save it with name “prometheus.yml”, and push it to OCP4 secret by using below command
oc create cm prometheus-config --from-file=prometheus.yaml
And mount it to Prometheus’s DeploymentConfig
oc volume dc/prometheus --add --name=prometheus-config --type=configmap --configmap-name=prometheus-config --mount-path=/etc/prometheus/
There is other approach of installating Prometheus and Grafana, and that is by using yml template. I cover those approach on my Github page,