Visualize Sync Metrics Data on OpenShift
Overview
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
-
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
-
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
-
Wait for the InfluxDB service to be created and running.
Step 2. Create the Grafana service
-
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
-
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_URLvalue.
Step 3. Add the InfluxDB data source to Grafana and create the sync dashboard
-
Login to the Grafana console with the default admin user (u: admin, p: admin)
-
Click on the dropdown on the top left corner, and select
Data Sources→Add data source-
Give it a name
influxdband mark it as thedefaultdata source. -
Set the type to be
InfluxDB -
Set the URL to be
http://influxdb-svc:8086and Database to beudp -
No authentication is required. Save the settings.
-
-
Click on the dropdown again, select
Dashboard→Import, and choose the sync-stats.json file in this repo.-
Give it a name, make sure choose the
influxdbdata source that is just created.
-
-
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
-
Pass the following value to
sync.setConfigfunction. 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);
-
Redeploy the app, and make sure it is running on OpenShift.
-
Refresh the dashboard. Make sure select the right value for the
hostvariable on the dashboard. You should start to see the metrics data in the dashboard.
