+++ title = "Configuration" description = "Configuration Docs" keywords = ["grafana", "configuration", "documentation"] type = "docs" [menu.docs] name = "Configuration" identifier = "config" parent = "admin" weight = 1 +++ # Configuration The Grafana back-end has a number of configuration options that can be specified in a `.ini` configuration file or specified using environment variables. > **Note.** Grafana needs to be restarted for any configuration changes to take effect. ## Comments In .ini Files Semicolons (the `;` char) are the standard way to comment out lines in a `.ini` file. A common problem is forgetting to uncomment a line in the `custom.ini` (or `grafana.ini`) file which causes the configuration option to be ignored. ## 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__ ``` Where the section name is the text within the brackets. Everything should be upper case, `.` should be replaced by `_`. For example, given these configuration settings: ```bash # default section instance_name = ${HOSTNAME} [security] admin_user = admin [auth.google] client_secret = 0ldS3cretKey ``` Then you can override them using: ```bash export GF_DEFAULT_INSTANCE_NAME=my-instance export GF_SECURITY_ADMIN_USER=true export GF_AUTH_GOOGLE_CLIENT_SECRET=newS3cretKey ```
## instance_name Set the name of the grafana-server instance. Used in logging and internal metrics and in clustering info. Defaults to: `${HOSTNAME}`, which will be replaced with environment variable `HOSTNAME`, if that is empty or does not exist Grafana will try to use system calls to get the machine name. ## [paths] ### data Path to where Grafana stores the sqlite3 database (if used), file based sessions (if used), and other data. This path is usually specified via command line in the init.d script or the systemd service file. ### temp_data_lifetime How long temporary images in `data` directory should be kept. Defaults to: `24h`. Supported modifiers: `h` (hours), `m` (minutes), for example: `168h`, `30m`, `10h30m`. Use `0` to never clean up temporary files. ### logs Path to where Grafana will store logs. This path is usually specified via command line in the init.d script or the systemd service file. It can be overridden in the configuration file or in the default environment variable file. ### plugins Directory where grafana will automatically scan and look for plugins ### provisioning Folder that contains [provisioning](/administration/provisioning) config files that grafana will apply on startup. Dashboards will be reloaded when the json files changes ## [server] ### http_addr The IP address to bind to. If empty will bind to all interfaces ### http_port The port to bind to, defaults to `3000`. To use port 80 you need to either give the Grafana binary permission for example: ```bash $ sudo setcap 'cap_net_bind_service=+ep' /usr/sbin/grafana-server ``` Or redirect port 80 to the Grafana port using: ```bash $ sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 3000 ``` Another way is put a webserver like Nginx or Apache in front of Grafana and have them proxy requests to Grafana. ### protocol `http`,`https` or `socket` > **Note** Grafana versions earlier than 3.0 are vulnerable to [POODLE](https://en.wikipedia.org/wiki/POODLE). So we strongly recommend to upgrade to 3.x or use a reverse proxy for ssl termination. ### socket Path where the socket should be created when `protocol=socket`. Please make sure that Grafana has appropriate permissions. ### domain This setting is only used in as a part of the `root_url` setting (see below). Important if you use GitHub or Google OAuth. ### enforce_domain Redirect to correct domain if host header does not match domain. Prevents DNS rebinding attacks. Default is false. ### root_url This is the full URL used to access Grafana from a web browser. This is important if you use Google or GitHub OAuth authentication (for the callback URL to be correct). > **Note** This setting is also important if you have a reverse proxy > in front of Grafana that exposes it through a subpath. In that > case add the subpath to the end of this URL setting. ### static_root_path The path to the directory where the front end files (HTML, JS, and CSS files). Default to `public` which is why the Grafana binary needs to be executed with working directory set to the installation path. ### enable_gzip Set this option to `true` to enable HTTP compression, this can improve transfer speed and bandwidth utilization. It is recommended that most users set it to `true`. By default it is set to `false` for compatibility reasons. ### cert_file Path to the certificate file (if `protocol` is set to `https`). ### cert_key Path to the certificate key file (if `protocol` is set to `https`). ### router_logging Set to true for Grafana to log all HTTP requests (not just errors). These are logged as Info level events to grafana log.
## [database] Grafana needs a database to store users and dashboards (and other things). By default it is configured to use `sqlite3` which is an embedded database (included in the main Grafana binary). ### url Use either URL or the other fields below to configure the database Example: `mysql://user:secret@host:port/database` ### type Either `mysql`, `postgres` or `sqlite3`, it's your choice. ### path Only applicable for `sqlite3` database. The file path where the database will be stored. ### host Only applicable to MySQL or Postgres. Includes IP or hostname and port or in case of unix sockets the path to it. For example, for MySQL running on the same host as Grafana: `host = 127.0.0.1:3306` or with unix sockets: `host = /var/run/mysqld/mysqld.sock` ### name The name of the Grafana database. Leave it set to `grafana` or some other name. ### user The database user (not applicable for `sqlite3`). ### password The database user's password (not applicable for `sqlite3`). If the password contains `#` or `;` you have to wrap it with triple quotes. Ex `"""#password;"""` ### ssl_mode For Postgres, use either `disable`, `require` or `verify-full`. For MySQL, use either `true`, `false`, or `skip-verify`. ### ca_cert_path The path to the CA certificate to use. On many linux systems, certs can be found in `/etc/ssl/certs`. ### client_key_path The path to the client key. Only if server requires client authentication. ### client_cert_path The path to the client cert. Only if server requires client authentication. ### server_cert_name The common name field of the certificate used by the `mysql` or `postgres` server. Not necessary if `ssl_mode` is set to `skip-verify`. ### max_idle_conn The maximum number of connections in the idle connection pool. ### max_open_conn The maximum number of open connections to the database. ### conn_max_lifetime Sets the maximum amount of time a connection may be reused. The default is 14400 (which means 14400 seconds or 4 hours). For MySQL, this setting should be shorter than the [`wait_timeout`](https://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_wait_timeout) variable. ### log_queries Set to `true` to log the sql calls and execution times. ### cache_mode For "sqlite3" only. [Shared cache](https://www.sqlite.org/sharedcache.html) setting used for connecting to the database. (private, shared) Defaults to private.
## [remote_cache] ### type Either `redis`, `memcached` or `database` default is `database` ### connstr The remote cache connection string. Leave empty when using `database` since it will use the primary database. Redis example config: `addr=127.0.0.1:6379,pool_size=100,db=grafana` Memcache example: `127.0.0.1:11211`
## [security] ### admin_user The name of the default Grafana admin user (who has full permissions). Defaults to `admin`. ### admin_password The password of the default Grafana admin. Set once on first-run. Defaults to `admin`. ### login_remember_days The number of days the keep me logged in / remember me cookie lasts. ### secret_key Used for signing some datasource settings like secrets and passwords. Cannot be changed without requiring an update to datasource settings to re-encode them. ### disable_gravatar Set to `true` to disable the use of Gravatar for user profile images. Default is `false`. ### data_source_proxy_whitelist Define a white list of allowed ips/domains to use in data sources. Format: `ip_or_domain:port` separated by spaces ### cookie_secure Set to `true` if you host Grafana behind HTTPS. Default is `false`. ### cookie_samesite Sets the `SameSite` cookie attribute and prevents the browser from sending this cookie along with cross-site requests. The main goal is mitigate the risk of cross-origin information leakage. It also provides some protection against cross-site request forgery attacks (CSRF), [read more here](https://www.owasp.org/index.php/SameSite). Valid values are `lax`, `strict` and `none`. Default is `lax`. ### allow_embedding When `false`, the HTTP header `X-Frame-Options: deny` will be set in Grafana HTTP responses which will instruct browsers to not allow rendering Grafana in a ``, `