Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

This page describes the steps to install a Prometheus monitoring server in your MediationZone deployment. The steps we provide in the example below involves setting following instructions detail how to set up the JMX exporter on your Platform for , enabling Prometheus to scrape the metrics from the Platform.

Prerequisites

The following must be completed before setting up Prometheus:

  • Download and install the version of Prometheus compatible with your bare metal setup. You can download Prometheus from Download | Prometheus.

    Note
    titleNote!





Prerequisites:
The following steps must be completed before installing Prometheus:



Configuring JMX exporter for Platform

You can enable the JMX exporter for your Platform. If you want Prometheus to scrape the metrics from Platform, you should configure the JMX exporter, as it exposes and exports all the metrics in your Platform for the Prometheus server to pick up.

...

Note
titleNote!

You need to expose the JMX port on your Platform if you have applied the changes to the platform.xml on an already installed Platform. Add this to the platform.xml file and restart the platform.

Code Block
<jdkarg value="-javaagent:common/lib/jmx_prometheus_javaagent-0.15.0.jar=9190:/mz/prometheus/prometheus-jmx-exporter.xml"/>



On Private Cloud and AWS

This is a step-by-step installation instruction, using helm to install Prometheus with or without persistence. As this is just one example provided to install Prometheus, you can definitely install the Prometheus server and adapter in however way you want to.

...

Info
titleInfo!

Only one instance of Prometheus is required in a Kubernetes cluster. This single Prometheus server will monitor and scrape for metrics from all the different namespaces in your Kubernetes cluster.

Prerequisite

You will need to install Helm3 first before installing Prometheus following the examples listed below. If you already have helm installed from when you installed , then you can skip this step.

Configuring JMX exporter for Platform

You can enable the JMX exporter for your Platform. If you want Prometheus to scrape the metrics from Platform, you should configure the JMX exporter, as it exposes and exports all the metrics in your Platform for the Prometheus server to pick up.

...

Info
titleExample: values.yaml file with JMX exporter enabled for Platform

This is an example of a values.yaml file where the JMX exporter is enabled for Platform on port 8888.

Code Block
mediationzone / values.yaml:
    jmx:
	  export:
        enabled: true
	    port: 8888


Installing Prometheus without Persistence

The following steps show how to install the Prometheus server without the use of persistence. Be aware that your metrics data will not be retained should your deployment be brought down. We do not recommend deploying Prometheus without persistence into a production environment.

  1. Add the helm repo for Prometheus.

    Code Block
    helm repo add prometheus-community https://prometheus-community.github.io/helm-charts


  2. Install Prometheus using the helm install command. For this example, we opted to install the Prometheus server in its own namespace called prometheus.  Enter the value of the port you want the Prometheus server node port to be configured with

    Code Block
    helm install -n <namespace> prometheus prometheus-community/prometheus \
      --set server.persistentVolume.enabled=false \
      --set server.service.type=NodePort \
      --set server.service.nodePort=<port> \
      --set alertmanager.persistentVolume.enabled=false


    Info
    titleExample: helm install Prometheus


    Code Block
    helm install -n prometheus prometheus prometheus-community/prometheus \
      --set server.persistentVolume.enabled=false \
      --set server.service.type=NodePort \
      --set server.service.nodePort=31010 \
      --set alertmanager.persistentVolume.enabled=false



Installing Prometheus with Persistence

The following steps show how to install the Prometheus server with the use of persistence volumes on your Kubernetes cluster.

  1. Create a yaml file and describe the Persistent Volume and Persistent Volume Claim for your Prometheus server. The example used here creates the persistent volume on an NFS file server that is mounted onto the cluster. The value set in nfs.path is the directory on the NFS file server that stores the metrics data.

    Info
    titleExample: Persistence for Prometheus


    Code Block
    apiVersion: v1
    kind: PersistentVolume
    metadata:
      name: prometheus
    spec:
      accessModes:
      - ReadWriteMany
      capacity:
        storage: 10Gi
      nfs:
        path: /export/snap/metrics/prometheus
        server: 192.154.14.120
      persistentVolumeReclaimPolicy: Retain
      storageClassName: prometheus-persistent
    ---
    apiVersion: v1
    kind: PersistentVolumeClaim
    metadata:
      name: prometheus-persistent
    spec:
      accessModes:
      - ReadWriteMany
      resources:
        requests:
          storage: 10Gi
      storageClassName: prometheus-persistent



  2. After creating the yaml file, run this command:

    Code Block
    kubectl apply -f <persistent volume yaml> -n <namespace>


  3. Add the helm repo for Prometheus.

    Code Block
    helm repo add prometheus-community https://prometheus-community.github.io/helm-charts


  4. Install Prometheus using the helm install command. For this example, we opted to install the Prometheus server in its own namespace called prometheus.  Enter the value of the port you want the Prometheus server node port to be configured with and set the name of the Persistent Volume Claim that you have created in the steps before.

    Code Block
    helm install -n <namespace> prometheus prometheus-community/prometheus \
      --set server.persistentVolume.enabled=true \
      --set server.persistentVolume.accessModes=ReadWriteMany \
      --set server.persistentVolume.existingClaim="prometheus-persistent" \
      --set server.service.type=NodePort \
      --set server.service.nodePort=<port> \
      --set alertmanager.persistentVolume.enabled=false


    Info
    titleExample: helm install Prometheus - with persistence


    Code Block
    helm install -n prometheus prometheus prometheus-community/prometheus \
      --set server.persistentVolume.enabled=true \
      --set server.persistentVolume.accessModes=ReadWriteMany \
      --set server.persistentVolume.existingClaim="prometheus-persistent" \
      --set server.service.type=NodePort \
      --set server.service.nodePort=31010 \
      --set alertmanager.persistentVolume.enabled=false



Verify the Prometheus Installation

This step will have you check that your Prometheus is deployed correctly.

  1. After installing the Prometheus server, you will be given an export command to use to acquire the URL and the Port for the Prometheus server. The command can look something like this:

    Code Block
    export NODE_PORT=$(kubectl get --namespace <namespace> -o jsonpath="{.spec.ports[0].nodePort}" services prometheus-server)
    export NODE_IP=$(kubectl get nodes --namespace <namespace> -o jsonpath="{.items[0].status.addresses[0].address}")


    Info
    titleExample: Exporting the value for Prometheus Node IP and Node Port


    Code Block
    $ export NODE_PORT=$(kubectl get --namespace prometheus -o jsonpath="{.spec.ports[0].nodePort}" services prometheus-server)
    $ export NODE_IP=$(kubectl get nodes --namespace prometheus -o jsonpath="{.items[0].status.addresses[0].address}")



  2. To generate the URL from the result of the two export commands above, use this echo command. Then copy the result to your browser.

    Code Block
    echo http://$NODE_IP:$NODE_PORT


    Info
    titleExample: Url for Prometheus GUI


    Code Block
    http://192.168.52.26:31010



Install Prometheus Adapter

Anchor
prom-adapter
prom-adapter

...