Initial configuration of Grafana
You can configure Grafana whether editing the grafana.ini
file or by specifying environment variables.
In this section, you will learn how to do it both ways.
Configuration files
Grafana comes with a default configuration file that you should not edit: defaults.ini
.
To override the settings in this file, you must edit grafana.ini
. This file is located – in Linux systems – in the /etc/grafana/grafana.ini
directory.
You can find the locations for different operating systems at https://grafana.com/docs/grafana/latest/administration/configuration/#config-file-locations.
All configuration options are shown here: https://grafana.com/docs/grafana/latest/administration/configuration/.
We will explore some basic options to start using Grafana. In later chapters, you will learn about some other specific configuration settings.
The app_mode
variable accepts two options: development and production. The default option is production
and you must keep it unless you are planning to do some development:
app_mode production
In the date_formats
section, you can set date and time formats used in graphs and date-time boxes. In this section, you will find several options.
full_date
is used to show a full date format where it is applicable.
Here’s an example:
full_date YYYY-MM-DD HH:mm:s
interval
options are used in the graph to show partial dates or times.
The default options are as follows:
interval_second = HH:mm:ss
interval_minute = HH:mm
interval_hour = MM/DD HH:mm
interval_day = MM/DD
interval_month = YYYY-MM
interval_year = YYYY
use_browser_locale
allows us to use date formats derived from the browser location. It is set to false
by default.
With default_timezone
, you can set your own time zone, or set it to use the browser location. The default option is the browser.
In the security
section, you can set the administration user and security-related options. Some of these options, such as admin username and password, can be edited from the web interface.
In the paths
section, you can see the paths that Grafana is using in your system.
In a Linux system, these paths are as follows:
data /var/lib/grafana
logs /var/log/grafana
plugins /var/lib/grafana/plugins
provisioning /etc/grafana/provisioning
Important Note
If you are using Docker to deploy Grafana, these paths cannot be modified in the configuration file. Instead, you will have to use environment variables.
You have now learned to use the configuration file to modify the behavior of Grafana. You also have seen the paths to important Grafana files.
In the next section, you will learn how to configure Grafana using environment variables.
Environment variables
In the previous section, you learned how to use environment variables with Docker. Now, you will see how to do this in the Linux host.
You can override any option in the configuration file using environment variables.
The syntax is as follows:
GF_<SectionName>_<KeyName>
So, if you want to change the admin user, you must type the following in the console:
export GF_SECURITY_ADMIN_USER=newadminuser
The same applies to every other option.
Note
You will have to restart Grafana for any configuration change to take effect.
Until here, you have learned how to install Grafana on-premises using different deployment options.
In the next section, you will learn how to use the Grafana Cloud service to avoid the installation and management process.