Monitoring Mobile Foundation on Red Hat OpenShift Container Platform

improve this page | report issue

Overview

This tutorial outlines how to integrate Prometheus to monitor Mobile Foundation running on Red Hat OpenShift Container Platform. Mobile Foundation provides monitoring capability by enabling mpMetrics-2.2 feature to monitor Mobile Foundation components that are instrumented with the MicroProfile metrics API. This helps to monitor the JVM and system level metrics of your Mobile Foundation containers. The default response formats to /metrics API request is of text format, which is compatible with Prometheus.

Procedure

You can enable monitoring of your own services by setting the techPreviewUserWorkload/enabled flag in the cluster monitoring ConfigMap.

Prerequisites

Following are the prerequisites before you begin the process of installing Mobile Foundation instance.

  • Make sure you have the cluster-monitoring-config ConfigMap object with the data/config.yaml section.

Complete the following steps to set up the monitoring for Mobile Foundation on OpenShift.

Steps

  1. Start editing the cluster-monitoring-config ConfigMap.
    $ oc -n openshift-monitoring edit configmap cluster-monitoring-config
    

    If cluster-monitoring-config is not present, then create cluster-monitoring-config.yaml and add the configuration present in step 2 and run the following command to create it.

    $ oc create -f cluster-monitoring-config -n openshift-monitoring
    
  2. Set the techPreviewUserWorkload setting to true under data/config.yaml.
    apiVersion: v1
    kind: ConfigMap
    metadata:
      name: cluster-monitoring-config
      namespace: openshift-monitoring
    data:
      config.yaml: |
        techPreviewUserWorkload:
          enabled: true
    
  3. Save the file to apply the changes. Monitoring your own services is enabled automatically.

  4. Optional: You can check that the prometheus-user-workload pods were created.
    $ oc -n openshift-user-workload-monitoring get pod
    NAME                                   READY   STATUS    RESTARTS   AGE
    prometheus-operator-85bbb7b64d-7jwjd   1/1     Running   0          3m24s
    prometheus-user-workload-0             5/5     Running   1          3m13sprprometheus-user-workload-1             5/5     Running   1          3m13s
    
  5. Create a ServiceMonitor for the Mobile Foundation services. Create a YAML file called mf-app-service-monitor.yaml for the ServiceMonitor configuration. Populate the file with the configuration for creating the ServiceMonitor. ```YAML apiVersion: monitoring.coreos.com/v1 kind: ServiceMonitor metadata: labels: k8s-app: prometheus-mf-monitor name: prometheus-mf-monitor namespace: spec: endpoints:
    • interval: 30s port: “9080” scheme: http selector: matchLabels: app: ibm-mf-server ```

    Note: Update to the namespace where Mobile Foundation deployments are running.

    This configuration makes OpenShift Monitoring scrape the metrics exposed by the service for deployed Mobile Foundation server.
    Apply the configuration file to the cluster.

      $ oc apply -f mf-app-service-monitor.yaml
    

    Similarly, you can create ServiceMonitor resources for Mobile Foundation Push, Live Update, Analytics and Application Center.

  6. Check that the ServiceMonitor is running.
    $ oc -n <mf-namespace> get servicemonitor
    NAME                         AGE
    prometheus-mf-monitor   44h
    

Accessing the Mobile Foundation metrics

After you have enabled monitoring for Mobile foundation, you can access the metrics of the service as a cluster administrator, as a developer, or as a user with view permissions for the project.

  • Access the Prometheus web console.
    • To access the metrics as a cluster administrator, go to the OpenShift Container Platform web console, switch to the Administrator Perspective, and click Monitoring → Metrics.
    • To access the metrics as a developer or a user with permissions, go to the OpenShift Container Platform web console, switch to the Developer Perspective, then click Advanced → Metrics. Select the project you want to see the metrics for.

Note: Mobile Foundation metric parameters start with base_*.

Some of the metric parameters are listed here.

  • base_gc_total
  • base_cpu_systemLoadAverage
  • base_thread_count
  • base_classloader_loadedClasses_count
  • base_jvm_uptime_seconds
  • base_thread_max_count

For more information on User Workload monitoring on OpenShift, see here.

Inclusive terminology note: The Mobile First Platform team is making changes to support the IBM® initiative to replace racially biased and other discriminatory language in our code and content with more inclusive language. While IBM values the use of inclusive language, terms that are outside of IBM's direct influence are sometimes required for the sake of maintaining user understanding. As other industry leaders join IBM in embracing the use of inclusive language, IBM will continue to update the documentation to reflect those changes.
Last modified on August 24, 2020