On this page
- What will Grafana do for me?
- How do I install Grafana on Ubuntu or Debian?
- How do I install Grafana on Rocky Linux or AlmaLinux?
- How do I keep Grafana on localhost?
- How do I publish Grafana over HTTPS?
- How do I add Prometheus as a data source?
- How do I get a useful dashboard quickly?
- How do I set up alerts?
- How do I upgrade, back up and troubleshoot?
- Questions
What will Grafana do for me?
Grafana draws dashboards and evaluates alerts on top of data you already collect. It does not store metrics itself: it reads them from data sources such as Prometheus, Loki for logs, InfluxDB, PostgreSQL or MySQL. One screen can then show CPU, memory, disk latency and HTTP errors side by side, with variables to switch between servers.
This guide installs Grafana OSS, the free open source edition. It works well on the same VPS as Prometheus for a small fleet; a 4 GB plan leaves comfortable room for both.
How do I install Grafana on Ubuntu or Debian?
Import the signing key into a keyring file, add the stable repository and install:
sudo apt install -y apt-transport-https wget gpg
sudo mkdir -p /etc/apt/keyrings
wget -q -O - https://apt.grafana.com/gpg.key | gpg --dearmor | sudo tee /etc/apt/keyrings/grafana.gpg > /dev/null
echo "deb [signed-by=/etc/apt/keyrings/grafana.gpg] https://apt.grafana.com stable main" | sudo tee /etc/apt/sources.list.d/grafana.list
sudo apt update
apt policy grafana
sudo apt install -y grafanaThe same repository also carries Loki and Alloy, which the log guide uses.
How do I install Grafana on Rocky Linux or AlmaLinux?
Create a repository file and install with dnf:
sudo tee /etc/yum.repos.d/grafana.repo > /dev/null <<'EOF'
[grafana]
name=grafana
baseurl=https://rpm.grafana.com
repo_gpgcheck=1
enabled=1
gpgcheck=1
gpgkey=https://rpm.grafana.com/gpg.key
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
EOF
sudo dnf install -y grafana
dnf info grafana | grep -E '^(Version|Release)'Accept the GPG key fingerprint when dnf asks for it.
How do I keep Grafana on localhost?
Edit /etc/grafana/grafana.ini before the first start. Settings are commented out with a semicolon by default; remove it and set the values in the right sections:
[server]
http_addr = 127.0.0.1
http_port = 3000
domain = grafana.example.net
root_url = https://grafana.example.net/
[security]
cookie_secure = true
[users]
allow_sign_up = false
[analytics]
reporting_enabled = falseStart the service and check its health endpoint, which also prints the version:
sudo systemctl daemon-reload
sudo systemctl enable --now grafana-server
sudo ss -tlnp | grep 3000
curl -s http://127.0.0.1:3000/api/healthThe listener should read 127.0.0.1:3000 and the health response should report the database as ok.
How do I publish Grafana over HTTPS?
Point an A record for grafana.example.net at your server (see DNS records) and add a Caddy site, following Caddy HTTPS:
grafana.example.net {
reverse_proxy 127.0.0.1:3000
}# Ubuntu and Debian
sudo ufw allow 80/tcp && sudo ufw allow 443/tcp
# Rocky Linux and AlmaLinux
sudo firewall-cmd --permanent --add-service=http --add-service=https
sudo firewall-cmd --reloadOpen the address and sign in with admin / admin; Grafana requires a new password straight away, so do this the moment the site comes up. Then enable two step login through an identity provider if you have one, or keep a long unique password. Only want private access? Skip Caddy entirely and use ssh -N -L 3000:127.0.0.1:3000 deploy@198.51.100.24.
How do I add Prometheus as a data source?
You can click through Connections, Data sources, but a provisioning file is repeatable and survives a rebuild. Create /etc/grafana/provisioning/datasources/prometheus.yaml:
apiVersion: 1
datasources:
- name: Prometheus
type: prometheus
access: proxy
url: http://127.0.0.1:9090
isDefault: truesudo systemctl restart grafana-server
sudo journalctl -u grafana-server -n 20 --no-pagerWhen Prometheus runs on a different server, do not expose it in plain HTTP across the internet: use its TLS and basic auth web config, then fill in basicAuth and secureJsonData in the same file, or connect through an SSH tunnel.
How do I get a useful dashboard quickly?
Import a community dashboard built for node_exporter. In Dashboards choose New, Import, enter the ID 1860 (Node Exporter Full), pick your Prometheus data source and save. You will see CPU, memory, disk, network and filesystem panels with a host selector at the top.
Afterwards, make your own small overview with only the panels you check daily. Three or four time series and a stat panel for free disk space are often more useful than a hundred graphs. Save dashboards as JSON in a Git repository so they can be restored or provisioned from /etc/grafana/provisioning/dashboards/.
How do I set up alerts?
Grafana alerting runs queries on a schedule and notifies contact points. Create a contact point (Telegram, Slack, Discord, webhook or email), then an alert rule, for example: node_filesystem_avail_bytes / node_filesystem_size_bytes < 0.1 for 10 minutes. Email needs SMTP settings in grafana.ini; use an authenticated relay on port 587, and ask support by ticket before relying on outgoing port 25. Press Test on every contact point before trusting it.
How do I upgrade, back up and troubleshoot?
Updates come through the package manager: sudo apt upgrade or sudo dnf upgrade, followed by sudo systemctl restart grafana-server. Back up /var/lib/grafana/grafana.db and /etc/grafana before major upgrades.
- Lost admin password:
sudo grafana cli --homepath /usr/share/grafana --config /etc/grafana/grafana.ini admin reset-admin-password NEW_LONG_PASSWORD. - Redirect loop or broken links:
root_urldoes not match the public address. - No data: open Explore, run
upagainst Prometheus and check that targets are healthy. - Service will not start: read
journalctl -u grafana-server; file permissions in/var/lib/grafanaare a common cause after manual copies.
Plans that fit this guide
Base city prices. Every plan includes a dedicated IPv4 address, IPv6, full root and all 18 images.
Questions about Grafana dashboards
Is Grafana OSS free?
Yes, the open source edition from the official repository is free to install and use on your own server.
What is the default login?
User admin, password admin, and Grafana forces a change on first login. Change it before anyone else can reach the page.
Can Grafana show logs too?
Yes. Add Loki as a data source and use Explore or log panels. See Loki and Alloy for logs.
Does it replace the console Usage graphs?
No, they serve different needs. The Usage graphs tab is the provider side view of each instance; Grafana shows what your own collectors measure inside the OS.
Which plan suits Grafana with Prometheus?
For a small fleet, 2 vCPU and 4 GB RAM are comfortable. Grow by deploying a larger plan and migrating, as described in move to a larger plan.
More in Monitoring and logs
- Netdata real-time monitoring
- Uptime Kuma status page
- Prometheus and node_exporter
- Zabbix monitoring
- Nagios Core
- Beszel lightweight monitoring
- Loki and Alloy for central logs
- Cacti graphs with SNMP
- Monit for self-healing services
- btop, htop and other live monitors
- Central logs with rsyslog
- Rotate logs with logrotate
- Read logs with journalctl
- Graylog log management
- Observium network monitoring
- Vector log and metrics pipeline