This page covers common configuration steps for Grafana deployments.
| Installation Method | Configuration Path |
|---|---|
| APT/DNF package | /etc/grafana/grafana.ini |
| Docker | Mounted volume (e.g., /etc/grafana/grafana.ini) |
| Custom binary | $GF_PATHS_CONFIG environment variable |
Edit /etc/grafana/grafana.ini:
[server]
# Protocol for the server to run (http or https)
protocol = http
# HTTP port to listen on
http_port = 3000
# Domain name for public access
domain = monitoring.example.com
# Full URL for public access
root_url = %(protocol)s://%(domain)s:%(http_port)s/
# Local IP address to bind to (use 0.0.0.0 for all interfaces)
http_addr = 0.0.0.0
# Enable gzip compression
enable_gzip = true
# Secret key for session encryption (change this!)
secret_key = your_secret_key_here
SQLite (default, good for small installations):
[database]
type = sqlite3
path = grafana.db
PostgreSQL (recommended for production):
[database]
type = postgres
host = localhost:5432
name = grafana
user = grafana
password = your_password
ssl_mode = disable
MySQL:
[database]
type = mysql
host = localhost:3306
name = grafana
user = grafana
password = your_password
Anonymous access (disable for production):
[auth.anonymous]
enabled = false
Basic authentication:
[auth]
disable_login_form = false
disable_initial_admin_creation = false
OAuth (example for GitHub):
[auth.github]
enabled = true
allow_sign_up = true
client_id = YOUR_CLIENT_ID
client_secret = YOUR_CLIENT_SECRET
scopes = user:email,read:org
auth_url = https://github.com/login/oauth/authorize
token_url = https://github.com/login/oauth/access_token
api_url = https://api.github.com/user
allowed_organizations = your-org
[alerting]
enabled = true
execute_alerts = true
[unified_alerting]
enabled = true
ha_peers = ""
[log]
mode = console file
level = info
[log.file]
log_rotate = true
max_lines = 1000000
max_size_shift = 28
daily_rotate = true
max_days = 7
Data sources can be configured via UI or provisioning files.
Create /etc/grafana/provisioning/datasources/prometheus.yml:
apiVersion: 1
datasources:
- name: Prometheus
type: prometheus
access: proxy
url: http://localhost:9090
isDefault: true
editable: false
jsonData:
timeInterval: "15s"
httpMethod: POST
Create /etc/grafana/provisioning/dashboards/default.yml:
apiVersion: 1
providers:
- name: 'Default'
orgId: 1
folder: ''
type: file
disableDeletion: false
updateIntervalSeconds: 30
options:
path: /etc/grafana/provisioning/dashboards
grafana-cli admin settings
sudo systemctl restart grafana-server
sudo systemctl status grafana-server
Check Grafana is running:
curl http://localhost:3000/api/health
Expected response:
{"commit":"abc123","database":"ok","version":"12.3.2"}
Grafana can be configured via environment variables (useful for Docker):
| Variable | Description | Example |
|---|---|---|
GF_SERVER_HTTP_PORT |
HTTP port | 3000 |
GF_SECURITY_ADMIN_PASSWORD |
Admin password | secure_password |
GF_INSTALL_PLUGINS |
Install plugins | grafana-clock-panel |
GF_PATHS_DATA |
Data directory | /var/lib/grafana |
GF_PATHS_LOGS |
Logs directory | /var/log/grafana |
Example Docker usage:
environment:
- GF_SECURITY_ADMIN_PASSWORD=secure_password
- GF_INSTALL_PLUGINS=grafana-clock-panel,grafana-piechart-panel
Running Grafana in regulated environments? We assist with:
Secure your deployment: office@linux-server-admin.com | Contact Page