> ## Content Index
> Fetch the complete content index at: https://blog.bajonczak.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# How To provisioning DataSources in Grafana with Kubernetes
- URL: https://blog.bajonczak.com/how-to-provsioning-datasources-in-grafana/
- Published: 2023-02-25T07:36:00.000Z
- Updated: 2026-08-13T04:03:41.000Z
- Author: Sascha Bajonczak
- Tags: DevOps, Observability

In my [last post](https://blog.bajonczak.com/how-to-provisioning-dashboards-in-grafana/) about Grafana, I described to you how I provisioned a configured dashboard in Grafana. This was very nice to use, but unfortunately, every dashboard requires a datasource to display data. You are able to provision this datasource too in your grafana setup.

# What is a DataSource?

The datasource is, yes.... the source for your data. This can be everything you need. There are several datasources available to select so I will concentrate on a single datasource to keep this simple. An application Insights (aka Azure Monitor).

# Requirements

You will need at first the necessary data from the azure monitor to use the telemetry data from this service. So according to [this](https://grafana.com/docs/grafana/latest/datasources/azure-monitor/?ref=blog.bajonczak.com), you have two choices. I will use here the simplest one that uses an App registration. Because when you use the service principal you must provide this principal to your service, in Azure it's not a complex problem but when you host it on your own it will get very difficult :).

So first of all, let's assume you [registered an Application](https://learn.microsoft.com/en-us/azure/active-directory/develop/quickstart-register-app?ref=blog.bajonczak.com) in your Azure Ad Tenant. Next, you have the following data after this process

- Tenant-ID (Guid)
- Client-ID (Guid)
- Client Secret

Also, You must fetch the **subscription Id**, in which the Azure monitor is running.

# The DataSource Configuration

Before deep diving into the configuration, we will define the data source in our yaml. This is a no-brainer just use this

You see that you must insert your gathered data into this JSON. Please pay attention to the **uid** Property. This value, which you will later use in your dashboard as a data source reference, I will show you later an example for this.

So you see also that this data source definition will be stored as configmap-"file" (called ds.yml) in Kubernetes. So after applying it with kubectl -f {yourfile.yml} it will be available within your Kubernetes.

# Let Grafana know about your datasources

Provisioning the file itself is not the only task, you must put it in a specific location so that Garfana recognizes this datasource definition. For this, you can use the volume mount points that I described above. As you saw in my post about provisioning the dashboard you will recognize that I provisioning the datasources in a separate mount point. Let's look at a snippet from the complete example:

Here you see that I will mount two volumes one for the dashboard definitions and one for the datasources. I will focus on the datasource now. The volume **grafana-datasources** will reference our datarouce configmap **my-grafana-datasources** declared above.

Next, we tell Kubernetes, at which location the file will be mounted, for this, you will use the volumeMounts entry that will reference the grafana-datasources volume and mount it at the location **/etc/grafana/provisioning/datasources**.

So when you start the grafana instance now you will notice in your datasource administration the Azure Monitor data source you are created

![](https://pub-3d6b5be904ac42e19eb06b614618c42e.r2.dev/images/2023/02/image-2.png)

# How to use your data source in your Dashboard

Remember the uid for your dashboard defined above? Now it's time to use it. Because the uid will define a unique id for your datasource. This uid you now can use in your dashboard definition for each panel. Just search in your definition for **datasource**, when you already exported a datasource that uses azure monitor data, then you can search for **grafana-azure-monitor-datasource**. Next, you will see the uid property, in this, you will set the uid from your datasource definition. This can then look like this:

![](https://pub-3d6b5be904ac42e19eb06b614618c42e.r2.dev/images/2023/02/image-3.png)

That's all. Now you have not only a provisioned dashboard, you also have to tighten it to a functional datasource too.

# Conclusion

In this article you saw, how simple it is to provision a datasource. So I think this will get more and more involved in the DevOps process that we (and of course you) will use. I hope that this article helps you to understand how Grafana can be used in the Kubernetes world and how you can design fancy dashboards without manually configuring the datasource later.

*I keep a short overview of the practical posts that still get the most use here:* [*Technical Field Notes*](https://blog.bajonczak.com/technical-field-notes/)*.*