Visualize Sync Metrics Data on OpenShift

Overview

This guide will go through the steps to help you setup InfluxDB and Grafana on OpenShift to receive metrics data from the RHMAP sync framework, and view them in a Grafana dashboard. At the end, you should have a dashboard look like this:

sync stats dashboard

Prerequisites

You should have an OpenShift cluster running somewhere. Since this guide will use persistent volumes to persist data, please make sure there are some of them available on the cluster. An example file is provided in this repo to help with that.

You should also have the OpenShift command line tool (oc) installed locally and target to the given OpenShift cluster.

You should also add the cluster as an environment on RHMAP and be able to deploy cloud apps to the cluster.

Step 1. Create the InfluxDB service

  1. Create a new OpenShift project. You can give whatever name you like. For example, let’s call it sync-metrics:

    oc new-project sync-metrics
  2. Find out what size of persistent volumes are available and choose one for InfluxDB. Then you can create the InfluxDB service with the influxdb template like this:

    export INFLUXDB_STORAGE=10Gi
    oc new-app -p STORAGE_SIZE="$INFLUXDB_STORAGE" -f ./influxdb-template.yaml
  3. Wait for the InfluxDB service to be created and running.

Step 2. Create the Grafana service

  1. Choose another persistent volume for Grafana, and also pick a URL for the Grafana route. Then you can create the Grafana service with the grafana template like this:

    export HOST_URL=perf.example.openshift.com
    export GRAFANA_STORAGE=5Gi
    oc new-app -p STORAGE_SIZE="$GRAFANA_STORAGE" -p HOST_URL="$HOST_URL" -f ./grafana-template.yaml
  2. Wait for the Grafana service to be created and running. Once it’s running, you should be able to access the Grafana console via the HOST_URL value.

Step 3. Add the InfluxDB data source to Grafana and create the sync dashboard

  1. Login to the Grafana console with the default admin user (u: admin, p: admin)

  2. Click on the dropdown on the top left corner, and select Data SourcesAdd data source

    1. Give it a name influxdb and mark it as the default data source.

    2. Set the type to be InfluxDB

    3. Set the URL to be http://influxdb-svc:8086 and Database to be udp

    4. No authentication is required. Save the settings.

  3. Click on the dropdown again, select DashboardImport, and choose the sync-stats.json file in this repo.

    1. Give it a name, make sure choose the influxdb data source that is just created.

  4. The dashboard should be created, but there is no data yet.

Step 4. Update the sync config of the app to send the metrics to the InfluxDB

  1. Pass the following value to sync.setConfig function. For more details about the host value of the InfluxDB, see Openshift Networking Guide.

    var syncConfig = {
      metricsInfluxdbHost: "influxdb-svc.sync-metrics.svc.cluster.local",
      metricsInfluxdbPort: 8087
    };
    mbaasApi.sync.setConfig(syncConfig);
  2. Redeploy the app, and make sure it is running on OpenShift.

  3. Refresh the dashboard. Make sure select the right value for the host variable on the dashboard. You should start to see the metrics data in the dashboard.