Utilize OpenShift to manage external services metrics

Why

Openshift 4 provided great metrics monitor suites, we can use them to monitor and create dashboard for both infra and application layer services; What’s more we can leverage that to manage external services and infra as well.

  1. The monitoring components are almost coming free with embedded in Openshift. They are managed by Openshift Cluster Monitoring operator which is stable, self-healing and well-structured.
  2. Manage and scale infra configuration like monitoring components in OpenShift is easier than doing it in VM, because it’s declarative nature and we can even manage them by gitops.
  3. Of course if you have both OpenShift Platform to manage container world and VM world to manage other business, you don’t have to manage two complicated Monitoring solutions for time and cost saving.

What

In this article I’m going to cover the following topic in order to demonstrate how to monitor external services on OpenShift Monitoring Component:

  1. Configuring OpenShift to enable user-define monitoring components
  2. Proxy external service in Openshift via Kubernetes service
  3. Create My Grafana Instance to host application dashboard for external service metrics
  4. (Optional) utilize node exporter to monitor external infra metrics

How

Exporting Quarkus applications by MicroProfile metrics

In this lab I’m going to use the Quarkus framework to demonstrate the application metric monitoring, the application example is a quarkus-todo-application in my github repo.

  1. Micrometer metrics
#Execute on my laptop
mvn quarkus:dev
#Test my metrics is actual exporting
curl http://localhost:8080/metrics|grep Prime
application_io_quarkus_sample_PrimeNumberChecker_checksTimer_rate_per_second gauge
application_io_quarkus_sample_PrimeNumberChecker_checksTimer_rate_per_second 9...#Build container images and push into a remote repo, you need to change to your accessible repo
podman build -f src/main/docker/Dockerfile.ubi . -t quay.io/rzhang/quarkus:todo-app-jvm-11-nodb
# log into my target virtual machine 192.168.2.10
ssh 192.168.2.10
podman run -d --name todo-app -p 8080:8080 quay.io/rzhang/quarkus:todo-app-jvm-11-nodb
curl http://192.168.2.10:8080/metrics|grep Prime
application_io_quarkus_sample_PrimeNumberChecker_checksTimer_rate_per_second gauge
application_io_quarkus_sample_PrimeNumberChecker_checksTimer_rate_per_second 9...

Configuring OpenShift to enable user-defined monitoring components

First let’s have a briefing on how Monitoring components are organized in OpenShift.

oc apply -f cluster-monitoring-config.yaml
>oc projects|grep monitoringopenshift-monitoringopenshift-user-workload-monitoring>oc get po -n openshift-user-workload-monitoringNAME READY STATUS RESTARTS AGEprometheus-operator-6bf7fbbbdd-m8fsl 2/2 Running 0 9dprometheus-user-workload-0 5/5 Running 0 23dprometheus-user-workload-1 5/5 Running 0 23dthanos-ruler-user-workload-0 3/3 Running 1 23dthanos-ruler-user-workload-1 3/3 Running 1 23d

Proxy external service in Openshift via Kubernetes service

>oc new-project external-service

Create Grafana instance to display external service metrics

Wouldn’t it be great if we can view our user-defined metric in grafana.

oc new-project my-grafana
Install grafana operator into my-grafana namespace

(Optional) Utilize node exporter to monitor external infra metrics

Please follow prometheus official documentation to install node_exporter to your vm or bare metal, then you would have the metrics available at, for example in my case:

Red Hat Senior Consultant. Focus on App Dev, DevOps, OpenShift technology.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store