2017-10-23 08:21:51 -05:00
+++
2017-10-27 09:37:38 -05:00
title = "Provisioning"
2017-10-23 08:21:51 -05:00
description = ""
2017-10-27 09:37:38 -05:00
keywords = ["grafana", "provisioning"]
2017-10-23 08:21:51 -05:00
type = "docs"
2018-01-31 09:20:14 -06:00
aliases = ["/installation/provisioning"]
2017-10-23 08:21:51 -05:00
[menu.docs]
parent = "admin"
weight = 8
+++
# Provisioning Grafana
2017-10-30 04:28:56 -05:00
## Config file
2018-01-14 00:57:48 -06:00
Checkout the [configuration ](/installation/configuration ) page for more information on what you can configure in `grafana.ini`
2017-10-30 04:28:56 -05:00
### Config file locations
- Default configuration from `$WORKING_DIR/conf/defaults.ini`
- Custom configuration from `$WORKING_DIR/conf/custom.ini`
- The custom configuration file path can be overridden using the `--config` parameter
> **Note.** If you have installed Grafana using the `deb` or `rpm`
> packages, then your configuration file is located at
> `/etc/grafana/grafana.ini`. This path is specified in the Grafana
> init.d script using `--config` file parameter.
### Using environment variables
All options in the configuration file (listed below) can be overridden
using environment variables using the syntax:
```bash
GF_< SectionName > _< KeyName >
```
Where the section name is the text within the brackets. Everything
2018-01-14 00:57:48 -06:00
should be upper case and `.` should be replaced by `_` . For example, given these configuration settings:
2017-10-30 04:28:56 -05:00
```bash
# default section
instance_name = ${HOSTNAME}
[security]
admin_user = admin
[auth.google]
client_secret = 0ldS3cretKey
```
2018-01-14 00:57:48 -06:00
Overriding will be done like so:
2017-10-30 04:28:56 -05:00
```bash
export GF_DEFAULT_INSTANCE_NAME=my-instance
export GF_SECURITY_ADMIN_USER=true
export GF_AUTH_GOOGLE_CLIENT_SECRET=newS3cretKey
```
< hr / >
## Configuration management tools
2018-01-14 00:57:48 -06:00
Currently we do not provide any scripts/manifests for configuring Grafana. Rather than spending time learning and creating scripts/manifests for each tool, we think our time is better spent making Grafana easier to provision. Therefore, we heavily relay on the expertise of the community.
2017-10-30 04:28:56 -05:00
2017-10-31 03:29:31 -05:00
Tool | Project
-----|------------
Puppet | [https://forge.puppet.com/puppet/grafana ](https://forge.puppet.com/puppet/grafana )
2017-12-01 14:26:14 -06:00
Ansible | [https://github.com/cloudalchemy/ansible-grafana ](https://github.com/cloudalchemy/ansible-grafana )
2017-10-31 03:29:31 -05:00
Chef | [https://github.com/JonathanTron/chef-grafana ](https://github.com/JonathanTron/chef-grafana )
Saltstack | [https://github.com/salt-formulas/salt-formula-grafana ](https://github.com/salt-formulas/salt-formula-grafana )
2017-10-30 04:28:56 -05:00
2018-01-14 00:57:48 -06:00
## Datasources
2017-10-23 08:21:51 -05:00
2017-12-05 11:44:31 -06:00
> This feature is available from v5.0
2017-10-23 08:21:51 -05:00
2017-12-07 08:23:14 -06:00
It's possible to manage datasources in Grafana by adding one or more yaml config files in the [`provisioning/datasources` ](/installation/configuration/#provisioning ) directory. Each config file can contain a list of `datasources` that will be added or updated during start up. If the datasource already exists, Grafana will update it to match the configuration file. The config file can also contain a list of datasources that should be deleted. That list is called `delete_datasources` . Grafana will delete datasources listed in `delete_datasources` before inserting/updating those in the `datasource` list.
2017-10-23 08:21:51 -05:00
2018-01-14 00:57:48 -06:00
### Running multiple Grafana instances.
If you are running multiple instances of Grafana you might run into problems if they have different versions of the `datasource.yaml` configuration file. The best way to solve this problem is to add a version number to each datasource in the configuration and increase it when you update the config. Grafana will only update datasources with the same or lower version number than specified in the config. That way, old configs cannot overwrite newer configs if they restart at the same time.
2017-10-27 09:37:38 -05:00
### Example datasource config file
```yaml
2018-02-12 08:17:32 -06:00
# config file version
apiVersion: 1
2017-10-27 09:37:38 -05:00
# list of datasources that should be deleted from the database
2018-02-12 08:17:32 -06:00
deleteDatasources:
2017-10-27 09:37:38 -05:00
- name: Graphite
2018-02-12 08:17:32 -06:00
orgId: 1
2017-10-27 09:37:38 -05:00
2018-01-14 00:57:48 -06:00
# list of datasources to insert/update depending
2018-02-12 08:17:32 -06:00
# whats available in the database
2017-10-27 09:37:38 -05:00
datasources:
# < string , required > name of the datasource. Required
- name: Graphite
# < string , required > datasource type. Required
type: graphite
# < string , required > access mode. direct or proxy. Required
access: proxy
2018-02-12 08:17:32 -06:00
# < int > org id. will default to orgId 1 if not specified
orgId: 1
2017-10-27 09:37:38 -05:00
# < string > url
url: http://localhost:8080
# < string > database password, if used
password:
# < string > database user, if used
user:
# < string > database name, if used
database:
# < bool > enable/disable basic auth
2018-02-12 08:17:32 -06:00
basicAuth:
2017-10-27 09:37:38 -05:00
# < string > basic auth username
2018-02-12 08:17:32 -06:00
basicAuthUser:
2017-10-27 09:37:38 -05:00
# < string > basic auth password
2018-02-12 08:17:32 -06:00
basicAuthPassword:
2017-10-27 09:37:38 -05:00
# < bool > enable/disable with credentials headers
2018-02-12 08:17:32 -06:00
withCredentials:
2017-10-27 09:37:38 -05:00
# < bool > mark as default datasource. Max one per org
2018-02-12 08:17:32 -06:00
isDefault:
2017-11-16 07:22:52 -06:00
# < map > fields that will be converted to json and stored in json_data
2018-02-12 08:17:32 -06:00
jsonData:
2017-11-16 07:22:52 -06:00
graphiteVersion: "1.1"
tlsAuth: true
tlsAuthWithCACert: true
# < string > json object of data that will be encrypted.
2018-02-12 08:17:32 -06:00
secureJsonData:
2017-11-16 07:22:52 -06:00
tlsCACert: "..."
tlsClientCert: "..."
tlsClientKey: "..."
2017-10-27 09:37:38 -05:00
version: 1
# < bool > allow users to edit datasources from the UI.
2017-11-16 07:22:52 -06:00
editable: false
2017-10-27 09:37:38 -05:00
```
2017-11-16 07:22:52 -06:00
#### Json data
2018-01-14 00:57:48 -06:00
Since not all datasources have the same configuration settings we only have the most common ones as fields. The rest should be stored as a json blob in the `json_data` field. Here are the most common settings that the core datasources use.
2017-11-16 07:22:52 -06:00
| Name | Type | Datasource |Description |
| ----| ---- | ---- | --- |
| tlsAuth | boolean | *All* | Enable TLS authentication using client cert configured in secure json data |
| tlsAuthWithCACert | boolean | *All* | Enable TLS authtication using CA cert |
2018-01-08 06:21:51 -06:00
| tlsSkipVerify | boolean | *All* | Controls whether a client verifies the server's certificate chain and host name. |
2017-11-16 07:22:52 -06:00
| graphiteVersion | string | Graphite | Graphite version |
| timeInterval | string | Elastic, Influxdb & Prometheus | Lowest interval/step value that should be used for this data source |
2018-01-14 00:57:48 -06:00
| esVersion | string | Elastic | Elasticsearch version |
| timeField | string | Elastic | Which field that should be used as timestamp |
2017-11-16 07:22:52 -06:00
| interval | string | Elastic | Index date time format |
| authType | string | Cloudwatch | Auth provider. keys/credentials/arn |
2018-01-14 00:57:48 -06:00
| assumeRoleArn | string | Cloudwatch | ARN of Assume Role |
2017-11-16 07:22:52 -06:00
| defaultRegion | string | Cloudwatch | AWS region |
2018-01-14 00:57:48 -06:00
| customMetricsNamespaces | string | Cloudwatch | Namespaces of Custom Metrics |
2017-11-16 07:22:52 -06:00
| tsdbVersion | string | OpenTsdb | Version |
| tsdbResolution | string | OpenTsdb | Resolution |
2018-01-14 00:57:48 -06:00
| sslmode | string | Postgre | SSLmode. 'disable', 'require', 'verify-ca' or 'verify-full' |
2017-11-16 07:22:52 -06:00
#### Secure Json data
2018-02-13 08:47:02 -06:00
`{"authType":"keys","defaultRegion":"us-west-2","timeField":"@timestamp"}`
2017-11-16 07:22:52 -06:00
2018-01-14 00:57:48 -06:00
Secure json data is a map of settings that will be encrypted with [secret key ](/installation/configuration/#secret-key ) from the Grafana config. The purpose of this is only to hide content from the users of the application. This should be used for storing TLS Cert and password that Grafana will append to the request on the server side. All of these settings are optional.
2017-11-16 07:22:52 -06:00
| Name | Type | Datasource | Description |
| ----| ---- | ---- | --- |
| tlsCACert | string | *All* |CA cert for out going requests |
| tlsClientCert | string | *All* |TLS Client cert for outgoing requests |
| tlsClientKey | string | *All* |TLS Client key for outgoing requests |
2018-01-14 00:57:48 -06:00
| password | string | Postgre | password |
| user | string | Postgre | user |
2017-12-07 08:23:14 -06:00
### Dashboards
2018-02-13 08:47:02 -06:00
It's possible to manage dashboards in Grafana by adding one or more yaml config files in the [`provisioning/dashboards` ](/installation/configuration/#provisioning ) directory. Each config file can contain a list of `dashboards providers` that will load dashboards into Grafana from the local filesystem.
2017-12-07 08:23:14 -06:00
2018-01-14 00:57:48 -06:00
The dashboard provider config file looks somewhat like this:
2017-12-07 08:23:14 -06:00
```yaml
2018-02-13 07:14:10 -06:00
apiVersion: 1
providers:
2017-12-07 08:23:14 -06:00
- name: 'default'
2018-02-13 07:14:10 -06:00
orgId: 1
2017-12-07 08:23:14 -06:00
folder: ''
type: file
options:
folder: /var/lib/grafana/dashboards
```
2018-01-14 00:57:48 -06:00
When Grafana starts, it will update/insert all dashboards available in the configured folders. If you modify the file, the dashboard will also be updated.
2018-02-13 08:47:02 -06:00
> **Note.** Provisioning allows you to overwrite existing dashboards
> which leads to problems if you re-use settings that are supposed to be unique.
> Be careful not to re-use the same `title` multiple times within a folder
> or `uid` within the same installation as this will cause weird behaviours.