In a previous tutorial we talked about how the Weave Monitor probe collects data from your Kubernetes cluster and stores them in Weave Cloud and how with Monitor you can visualise the insights of your infrastructure as well as those of your applications. However, we often hear our customers that they want to hook up the metrics collected by Monitor but visualise them using Grafana. In this tutorial we are going to explain how to do so, again with The Sock Shop as the reference application. By the end of this tutorial you should end up with something like this:

Kubernetes Resources

Sock Shop Resources

Getting Started

We base this tutorial on the premise that you have already setup a Kubernetes cluster in Google Cloud from the previous tutorial. If you haven’t done so yet, you must first go back and follow the steps mentioned there and then come back here.

Configure Grafana

For Grafana to be able to pull data from Weave Cloud we are first going to need to supply the credentials necessary for it to be able to talk to the Weave Monitor API. Open the file deploy/kubernetes/manifests-monitoring/grafana-configmap.yaml and find the block that says prometheus-datasource.json and then make sure that it looks like the example down below:

prometheus-datasource.json: |
  "name":              "prometheus",
  "type":              "prometheus",
  "url":               "",
  "access":            "proxy",
  "basicAuth":         true,
  "basicAuthUser":     "weave",
  "basicAuthPassword": "<weave cloud token here>"

Don’t forget to add your Weave Cloud token to the basicAuthPassword field.

Deploy Grafana

To deploy Grafana to the cluster:

kubectl create namespace monitoring
kubectl apply -f deploy/kubernetes/manifests-monitoring/grafana-configmap.yaml \
  -f deploy/kubernetes/manifests-monitoring/grafana-dep.yaml \
  -f deploy/kubernetes/manifests-monitoring/grafana-svc.yaml \
  -f deploy/kubernetes/manifests-monitoring/grafana-import-dash-batch.yaml

Accessing Grafana

Now we need to figure out the public IP of our Grafana instance. Kubernetes has the answer to that:

kubectl get svc -n monitoring | grep grafana | awk '{ print $3 }'

Take that IP and open it up on your browser.

The default user/password is admin:admin. You should now be able to see the dashboards for Kubernetes and for the Shop.