Search for a command to run...
Install Grafana 13.2 on Linux, Windows, macOS, Docker and Kubernetes, connect Prometheus as a data source, and size the deployment for production.
Grafana is the visualization layer for metrics, logs and traces. It queries Prometheus, Loki, Tempo, Elasticsearch and dozens of other backends, and turns them into dashboards and alerts.
Grafana 13.2.4 · the official apt.grafana.com and rpm.grafana.com repositories ·
the grafana server binary · MySQL 8.0+ or PostgreSQL 12+ for production
Grafana Labs now recommends the Enterprise edition — it is functionally identical
to OSS and free to use, with the Enterprise feature set unlocked by a licence. The
package is grafana-enterprise; grafana is still the OSS package.
| Tier | CPU | Memory | Disk | Instances |
|---|---|---|---|---|
| Small (under 25 users) | 2 cores | 2–4 GB | 10–20 GB SSD | 1 |
| Medium (25–200 users) | 4–8 cores | 8–16 GB | 20–50 GB SSD | 2 (load balanced) |
| Large (200+ users) | 8–16+ cores | 16–32+ GB | 50+ GB SSD | 3+ (load balanced) |
# Prerequisites
sudo apt-get install -y apt-transport-https wget gnupg
# Import the GPG key into a keyring
sudo mkdir -p /etc/apt/keyrings
sudo wget -O /etc/apt/keyrings/grafana.asc https://apt.grafana.com/gpg-full.key
sudo chmod 644 /etc/apt/keyrings/grafana.asc
# Add the repository
echo "deb [signed-by=/etc/apt/keyrings/grafana.asc] https://apt.grafana.com stable main" \
| sudo tee /etc/apt/sources.list.d/grafana.list
# Install
sudo apt-get update
sudo apt-get install -y grafana # OSS
# sudo apt-get install -y grafana-enterprise # Enterprise
# Start and enable the service
sudo systemctl enable --now grafana-server
sudo systemctl status grafana-serverThe old apt-key add command no longer exists on Ubuntu 22.04+ and Debian 12. The
key now lives in /etc/apt/keyrings/grafana.asc and is referenced with
signed-by=.
# The service is running
sudo systemctl status grafana-server
# The health endpoint
curl -s http://localhost:3000/api/health
# The version
curl -s http://localhost:3000/api/health | jq .Open http://localhost:3000 and sign in with admin / admin — Grafana asks you to
change the password immediately.
Grafana reads /etc/grafana/grafana.ini. Every setting can also be set with an
environment variable: GF_<SECTION>_<KEY>, for example GF_SECURITY_ADMIN_PASSWORD or
GF_SERVER_HTTP_PORT.
[server]
http_port = 3000
domain = grafana.example.com
root_url = https://grafana.example.com
[security]
admin_user = admin
admin_password = change-me
allow_sign_up = false
cookie_secure = true
# Set to "none" when Grafana runs behind a proxy that terminates TLS
cookie_samesite = strict
[users]
allow_sign_up = false
default_theme = dark
[auth.anonymous]
enabled = false
[auth.basic]
enabled = true
[auth.oauth.github]
enabled = true
client_id = your-client-id
client_secret = your-client-secret
scopes = user:email
allow_sign_up = true
[database]
type = postgres
host = localhost:5432
name = grafana
user = grafana
password = your-password
ssl_mode = require
[smtp]
enabled = true
host = smtp.example.com:587
user = grafana@example.com
password = your-app-password
from_address = grafana@example.com
from_name = Grafana
[unified_alerting]
enabled = true
[alerting]
enabled = trueWithout it, Grafana generates links with localhost, and OAuth redirects and
"email me" links break.
http://prometheus:9090 in Docker, or
http://localhost:9090)# You can also provision it from a file# /etc/grafana/provisioning/datasources/prometheus.yaml
apiVersion: 1
datasources:
- name: Prometheus
type: prometheus
access: proxy
url: http://localhost:9090
isDefault: true
editable: true# /etc/grafana/provisioning/datasources/datasources.yaml
apiVersion: 1
datasources:
- name: Prometheus
type: prometheus
access: proxy
url: http://prometheus:9090
isDefault: true# /etc/grafana/provisioning/dashboards/dashboards.yaml
apiVersion: 1
providers:
- name: 'default'
orgId: 1
folder: ''
type: file
disableDeletion: false
updateIntervalSeconds: 30
options:
path: /etc/grafana/dashboards# Generate a certificate
sudo mkdir -p /etc/grafana/ssl
sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
-keyout /etc/grafana/ssl/grafana.key \
-out /etc/grafana/ssl/grafana.crt
sudo chown -R grafana:grafana /etc/grafana/ssl[server]
protocol = https
cert_file = /etc/grafana/ssl/grafana.crt
cert_key = /etc/grafana/ssl/grafana.key# Check the current version
sudo grafana-server -v
# or
curl -s http://localhost:3000/api/health
# Upgrade the package
sudo apt-get update && sudo apt-get install --only-upgrade grafana
sudo systemctl restart grafana-server# Back up before an upgrade
sudo systemctl stop grafana-server
sudo tar -czf /var/backups/grafana-$(date +%F).tar.gz -C /var/lib/grafana .
sudo systemctl start grafana-serverroot_url, cookie_secure and cookie_samesite before you put Grafana
behind a proxy./var/lib/grafana (plugins, dashboards stored on
disk).Install Prometheus 3.15 with node_exporter 1.12, configure scraping and alerting in the 3.x format, and understand the breaking changes when upgrading from 2.x.
Install Nagios Core 4.5.14 and the Nagios Plugins on Linux, configure hosts and services, and verify the checks that keep your infrastructure honest.