Installing Prometheus

  1. Before installing Prometheus, make sure that your OpenShift cluster is up and running by issuing the following command:
./oc cluster status
Web console URL: https://127.0.0.1:8443/console/
Config is at host directory
Volumes are at host directory
Persistent volumes are at host directory /opt/rh/okd/3.11/openshift.local.clusterup/openshift.local.pv
Data will be discarded when cluster is destroyed
  1. Use the following code in case of failure:
Error: OpenShift cluster is not running
  1. Start the cluster as follows:
./oc cluster up --server-loglevel=9
Getting a Docker client ...
Checking if image openshift/origin-control-plane:v3.11 is available ...
Checking type of volume mount ...
Determining server IP ...
Checking if OpenShift is already running ...
Checking for supported Docker version (=>1.22) ...
Checking if insecured registry is configured properly in Docker ...
Checking if required ports are available ...
Checking if OpenShift client is configured properly ...
Checking if image openshift/origin-control-plane:v3.11 is available ...
Starting OpenShift using openshift/origin-control-plane:v3.11 ...
...
Server Information ...
OpenShift server started.
The server is accessible via web console at:
https://127.0.0.1:8443
  1. Once the cluster is available, login as developer, as follows:
./oc login -u developer -p developer
  1. Create a project called monitoring:
./oc new-project monitoring
  1. Now use project monitoring on the https://127.0.0.1:8443 server. You can add applications to this project with the new-app command. For example, try the following:
oc new-app centos/ruby-25-centos7~https://github.com/sclorg/ruby-ex.git

This will build a new example application in Ruby.

  1. Now deploy the Prometheus platform, which is already available as a Docker image from the Docker.io repository, as follows:
./oc new-app prom/prometheus

--> Found Docker image 5517f70 (45 hours old) from Docker Hub for "prom/prometheus"

An image stream tag will be created as prometheus:latest, which will track this image. This image will be deployed in the deployment config called prometheus. Port 9090/tcp will be load-balanced by the prometheus service. Other containers can access this service through the prometheus host name. This image declares volumes and will default to use non-persistent, host-local storage.

  1. You can add persistent volumes later by running volume dc/prometheus --add ...:
--> Creating resources ...
imagestream.image.openshift.io "prometheus" created
deploymentconfig.apps.openshift.io "prometheus" created
service "prometheus" created
--> Success
  1. Expose the service by executing the following commands:
'oc expose svc/prometheus'
  1. Run oc status to view your app.
  2. Let's point the browser on the Web console and check the overview of the Prometheus deployment.

The Web console should look as follows:

  1. The Prometheus platform is still not available, so its service needs to be exported as route, as follows:
./oc expose service prometheus

route.route.openshift.io/prometheus exposed
  1. Now, click on the link representing the route to view the Prometheus application. The page should be similar to the following:

  1. To see where Prometheus is grasping the metrics from, select the voice Targets from the Status menu item, as follows:

As you can see, Prometheus is grasping metrics from itself.

  1. To see all of the available metrics, set the context path of the Prometheus application to metrics, and you should see a long list of metrics, along with their values.

A full reference of the metrics can be found at https://github.com/PacktPublishing/Hands-On-Cloud-Native-Microservices-with-Jakarta-EE/tree/master/ch10/metrics

  1. If you try to execute the PromQL process_cpu_seconds_total, which corresponds to the total user and system CPU time spent in seconds, you should see the Graph, as depicted in the following screenshot:

As you can see, the look and feel of the Prometheus interface is not the best that you will desire—that's why most the monitoring dashboard relies on Grafana. We will talk about Grafana later in this chapter.

Before installing Grafana, it is worth mentioning that the metrics provided by Prometheus are not enough for a containers-based cloud solution such as OpenShift. Metrics regarding hosts, containers, and pods are mandatory. For this purpose, the Node-exporter comes into play.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset