In this lecture,
I'm going to talk about Grafana provisioning.
It's an optional lecture.
You don't have to use Grafana provisioning,
but it's a very useful way of getting your configuration
on Grafana, using files rather than using the UI.
And if you are in the infrastructure team
like you are a DevOps engineer or an Azure,
then you might actually find this lecture pretty interesting
because this lecture will show you how to
make Grafana more stateless so that all configuration
is in code and at the state is saved in a database.
In one of the first lectures I showed you how to setup
Grafana using the UI.
So we just add the dashboards
and the data source using the web UI.
Rather than using UI, you can also use YAML
and JSON files to provision Grafana with data sources
and dashboards.
This is a much more powerful way of using Grafana,
as you can test new dashboards first on a dev or test server
and then import the newly created dashboards
to your production.
Instance, you can do the import manually through the UI
or using YAML and JSON files.
When using files, instead of doing it in the UI,
you can keep fast within version control.
For example, you get to keep changes,
revisions and backups.
The confirmation of Grafana is all kept in etc/grafana.
So if you have a look at etc/grafana,
we'll see that we have a grafana.ini
this is the main configuration file.
We can also configure ldap
and we also have a provisioning folder.
And in this provision folder,
we have dashboards and data sources.
So here we can put the YAML files
with the configuration that is needed for provisioning.
And that's what I'm going to show you in a demo.
The data itself is kept in var/lib/grafana.
So here in var/lib/grafana you have the dashboards,
the database, plugins and the sessions.
So these were temporary files for database
for the plugin that you install and for sessions.
The database is a local database,
but you can also configure in grafana.ini,
remote database, like a MySQL or Postgres.
So you can change the database
and the paths in etc/grafana/grafana.ini
and this is an extract of this file.
So it's an ini file, we have two sections here.
We have paths and database, and here in paths
you see where you can override the data path,
the lock path, plugin paths, and so on
if you're not happy with the defaults.
We are just going to keep the defaults because our defaults
on our Ubuntu machine is gonna be that in etc/grafana
we're gonna have the provisioning done,
so we don't have to change any paths here.
Then you have the database confirmation,
SQL Lite is just a file on the file system
but you can also use MySQL or Postgres
to have the state removed.
And then you can create a more stateless Grafana
where less files are saved locally.
And most of the state is then kept in a remote database.
In the next demo, I will then show you
how to provision the data source and dashboards.