This page covers configuration for Grafana deployments.
| File | Purpose |
|---|---|
/etc/grafana/grafana.ini |
Main configuration file |
/etc/grafana/provisioning/ |
Provisioned data sources and dashboards |
/var/lib/grafana/ |
Database and plugins |
[server]
# Protocol: http, https, h2, socket
protocol = http
# HTTP port
http_port = 3000
# Domain for URLs
domain = grafana.example.com
# Root URL
root_url = %(protocol)s://%(domain)s:%(http_port)s/
# Enable gzip compression
enable_gzip = true
[database]
# SQLite (default)
type = sqlite3
path = grafana.db
# PostgreSQL
# type = postgres
# host = 127.0.0.1:5432
# name = grafana
# user = grafana
# password = secret
# MySQL
# type = mysql
# host = 127.0.0.1:3306
# database = grafana
# user = grafana
# password = secret
[auth]
# Disable login form
disable_login_form = false
# OAuth settings
[auth.generic_oauth]
enabled = true
client_id = your_client_id
client_secret = your_client_secret
scopes = user:email
auth_url = https://oauth.example.com/authorize
token_url = https://oauth.example.com/oauth/token
api_url = https://oauth.example.com/user
[security]
# Admin credentials (change in production!)
admin_user = admin
admin_password = changeme
# Secret key for sessions
secret_key = SW2YcwTIb9zpOOhoPsMm
# Disable gravatar
disable_gravatar = true
# Cookie settings
cookie_secure = true
cookie_samesite = strict
[alerting]
enabled = true
execute_alerts = true
[unified_alerting]
enabled = true
ha_peers = ""
Create /etc/grafana/provisioning/datasources/datasources.yml:
apiVersion: 1
datasources:
- name: Prometheus
type: prometheus
access: proxy
url: http://prometheus:9090
isDefault: true
editable: false
- name: InfluxDB
type: influxdb
access: proxy
url: http://influxdb:8086
database: metrics
editable: false
Create /etc/grafana/provisioning/dashboards/dashboards.yml:
apiVersion: 1
providers:
- name: 'Default'
orgId: 1
folder: ''
type: file
disableDeletion: false
updateIntervalSeconds: 30
options:
path: /var/lib/grafana/dashboards
Grafana supports environment variable overrides:
# Server settings
GF_SERVER_HTTP_PORT=3000
GF_SERVER_DOMAIN=grafana.example.com
# Database
GF_DATABASE_TYPE=postgres
GF_DATABASE_HOST=localhost:5432
# Security
GF_SECURITY_ADMIN_USER=admin
GF_SECURITY_ADMIN_PASSWORD=secret
# Verify configuration
grafana-cli admin settings
# Check server status
systemctl status grafana-server
# Restart Grafana
sudo systemctl restart grafana-server
# Check status
sudo systemctl status grafana-server
# Check logs
sudo journalctl -u grafana-server -f
# Test HTTP endpoint
curl -I http://localhost:3000/api/health