Grafana on Cloud run

bhanu chandra
2 min readMay 15, 2021

Google cloud run is the serverless for the containers where you have the freedom of choosing your programming language, configuration and OS flavor and packaging them as container and deploy. Cloud run will do the Kubernetes for you, it will deploy the container with all configurations and scale up or down based on your traffic.

While in my previous posts I did tried flask program to be deployed on cloud run, this time I am looking at some dashboarding to use cloud run or Knative deployment.

The Requirement is to create a pre-loaded grafana with all datasources and dashboards installed so that you can share something to your leadership as live dashboard instead a ppt.

The Dockerfile will look like below.

If I talk about the Dockerfile: First line is more about which image to be used as base for the container. Next couple of lines uploads the datasource config and dashboard configs into your container and the grafana cli command will install the needed plugins and certain environment variables set to enable anonymous login.

You can refer the following is github repo to look at the full code to see how you can run the grafana with custom plugins installed and data sources, dashboards baked in . https://github.com/bhanuchandras/cloud-run-grafana

The docker cmds for testing locally or pushing to gcr is given.

when it comes to creating a gcloud run service it is pretty simple, let me share the screenshots for easier understanding.

gif with screenshots of gcloud run service configs

Once you are good with the configs gcloud run service hit the deploy and wait for the deployment to complete.

You should able to see the service url which would be ready to share.

Couple of limitations of gcloud run at this moment I realized are:

  • It would have been easier if I could mount a volume with config maps. This is available with knative/Anthos but not on the gloud run on gcp.
  • gcloud run serivce only picks up latest image at the point of deployment and later when you service is scaled to zero and again spin up it wont pull latest without new deployment, if your image is updated meanwhile . Hope you understand what I meant. If you are changing image run your deployment again.

Hope you enjoyed the quick and dirty dashboard instead of ppt’s to share your pitch, let me know your thoughts.

--

--