Skip to content

Latest commit

 

History

History
114 lines (72 loc) · 2.58 KB

07-prometheus.md

File metadata and controls

114 lines (72 loc) · 2.58 KB

App monitoring with prometheus

Create a new project

oc new-project userXY-prometheus

deploy example app

Clone the techlab Git repository, if you do not have it already available.

git clone REPO_URL/techlab.git

Navigate to the root directory of the git repository from gogs (cd techlab).

Create a new app.

oc new-app fabric8/s2i-java~data/prometheus-app --name prometheus-app -l app=prometheus-app

The first build will fail because of the missing binary input.

start build:

oc start-build prometheus-app --from-dir=data/prometheus-app --follow

Expose the service as route

oc create route edge --service=prometheus-app

deploy prometheus

Create the prometheus instance

oc new-app -f data/prometheus/prometheus3.7_without_clusterrole.yaml -p NAMESPACE=$(oc project --short)

Use route with name prometheus to see the Prometheus UI. You will need to log in with your OpenShift user.

Graph tab

Select as an example the metric for process_cpu_seconds_total

Click on Execute and see the Graph and Console.

Status tab

There you can inspect the lots of informations like flags, configuration, rules an so on.

On the Targets view, there should be a list of all service endpoints of Prometheus itself.

Check with the port numbers which services do not expose their metrics.

configure app to be scraped

Extend deployment configuration of the prometheus-app with prometheus endpoint informations.

spec
...
  template:
    metadata:
      annotations:
        prometheus.io/path: /actuator/prometheus
        prometheus.io/port: "8080"
        prometheus.io/scrape: "true"

Check the changes on the targets view of Prometheus (Status -> Targets): https://prometheus-userXY-prometheus.techlab-apps.puzzle.ch/targets

Is the prometheus-app pod visible? Is it UP?

Note: It can take some time until the pod is listed.

configure service to be scraped

Extend service configuration of the prometheus-app service.

metadata:
  annotations:
    prometheus.io/scrape: "true"
    prometheus.io/scheme: http
    prometheus.io/port: "8080"

get custom metrics

Go inside the Prometheus Graph tab to see the custom metrics of the prometheus-app.

Select the metric for meetup_thumbs_up_count_total.

Click on Execute and see the Graph and Console.

Click on the thumbs-up icons inside the prometheus-app. Reload the page and give some more thumbs-up.

You should then see the new count of the metric.

Scale up

Scale the prometheus-app up to multiple pods.

Do you find the new pods inside Prometheus?