How do I implement Prometheus monitoring in Openshift projects?

2/12/2019

We have an openshift container platform url that contains multiple projects like

  • project1
  • project2
  • project3

Each project contains several pods that we are currently monitoring with NewRelic like

  • pod1
  • pod2
  • pod3

We are trying to implement Prometheus + Grafana for all these projects separately.

It's too confusing with online articles as none of them described with the configuration that we have now.

Where do we start?

What do we add to docker images?

Is there any procedure to monitor the containers using cAdvisor on openshift?

Some say we need to add maven dependency in project. Some say we need to modify the code. Some say we need to add prometheus annotations for docker containers. Some say add node-exporter. What is the node-exporter in first place? Is it another container that looks for containers metrics? Can I install that as part of my docker images? Can anyone point me to an article or something with similar configuration?

-- Tywin Lannister
docker
kubernetes
openshift-enterprise
openshift-origin
prometheus

1 Answer

2/15/2019

Your question is pretty broad, so the answer will be the same :) Just to clarify - in your question:

implement Prometheus + Grafana for all these projects separately

Are going to have for each project dedicated installation of Kubernetes? Prometheus + Grfana? Or you are going to have 1 cluster for all of them?

In general, I think, the answer should be:

  1. Use Prometheus Operator as recommended (https://github.com/coreos/prometheus-operator)
  2. Once operator installed - you'll be able to get most of your data just by config changes - for example, you will get the Grafa and Node Exporters in the cluster by single config changes
  3. In our case (we are not running Open Shift, but vanilla k8s cluster) - we are running multiple namespaces (like your projects), which has it representation in Prometheus
  4. To be able to monitor pod's "applicational metrics", you need to use Prometheus client for your language, and to tell Prometheus to "scrap" the metrics (usually, it is done by ServiceMonitors).

Hope this will shed some light.

-- evgenyl
Source: StackOverflow