How To provisioning Dashboards in Grafana

Monitoring Nov 18, 2022

Grafana is a nice hand tool, after the first setup, you will have a nice empty system that you can configure on your own. But since we are all living in a DevOps world, you must find a solution to pre-provision a Dashboard that matches your needs.

Let’s assume you are running a Kubernetes, that is provisioning some microservices. These services will provide some metrics that will be fetched by Prometheus and these will be displayed by grafana. Now you want a nice fancy dashboard, but every time when grafana will is or you setup another system, you get an empty dashboard. In this post, you will learn how you can deliver a predefined dashboard on the DevOps way.

The base setup

First of all, you must create a Grafana instance my Kubernetes definition looks like the following:

This will create a plain Grafana instance without saving any data into the monitoring namespace. So the next step is to create a data source definition for your Prometheus source. That will be provisioned with grafana too.

Create the Datasource definition

For the Datasource, we create a configMap into our Kubernetes server. This will hold the configuration file for us in a centralized place. The config for the Prometheus data source looks like this:

In this, my Prometheus is running into the service port called prometheus-service.monitoring . This Datasource will be not editable so that now the user can`t accidentally misconfigure it.

The next step is to configure a small dashboard that will apply some data from our Prometheus instance.