Grafana as a Service
Introduction
In this guide Grafana will be setup on Ubuntu 24.04 as a service.
Alternate Installation Methods
Grafana can also be setup to run in Docker or in the cloud with Grafana Cloud. One benefit of running Grafana locally is that it is a much cleaner installation. With Grafana cloud you get a lot of prebuilt data sources and dashboards which can make it more "busy" than with a local installation.
OSS vs Enterprise
There are two versions: OSS (open source) and Enterprise. They are both free and have the same features. If you may want to get a license and pay for Grafana then use the Enterprise version as it can be unlocked without needing to reinstall. I will use the OSS version in this guide.
apt vs .deb
There are two ways to install Grafana as a service, both are covered in this wiki. The first way is manually adding the apt package and installing via apt. The second method is downloading the .deb file and installing via dpkg. When using apt, you can easily update Grafana to the latest version via apt. apt will also automatically install the dependencies. This is my preferred method, but if you want more control over updates then you can just install the .deb
Installation via CLI
First identify the latest version on the Grafana Downloads page. At the time of writing this wiki, the latest version is grafana_11.3.0_amd64.deb
and will be used in this wiki.
Install dependencies
sudo apt-get install -y apt-transport-https software-properties-common wget
Import the GPG key
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
Add repo
echo "deb [signed-by=/etc/apt/keyrings/grafana.gpg] https://apt.grafana.com stable main" | sudo tee -a /etc/apt/sources.list.d/grafana.list
Update packages
sudo apt-get update
Install Grafana.
sudo apt-get install grafana
Installation via deb
First identify the latest version on the Grafana Downloads page. At the time of writing this wiki, the latest version is grafana_11.3.0_amd64.deb
and will be used in this wiki.
Install dependencies
sudo apt-get install -y adduser libfontconfig1 musl
Download
Download the isntall package to home folder
wget -P ~/ https://dl.grafana.com/oss/release/grafana_11.3.0_amd64.deb
Install via dpkg
sudo dpkg -i ~/grafana_11.3.0_amd64.deb
Start and Enable the Service
By default, the grafana service is not started after the installation. Grafana will run on port 3000, if you need to change the port that Grafana runs on (skip to Reload the daemon
if you do not need to change the port):
Configure Port
sudo nano /etc/grafana/grafana.ini
Then identify the section where it specifies the http_port
, remove the leading ;
and update the port to one that is available on your host. Then save the file with ctrl + x
, then y
, then enter
.
Reload the Daemon
sudo systemctl daemon-reload
Start Grafana Service
sudo systemctl start grafana-server
Verify
sudo systemctl status grafana-server
Enable Service
To automatically start the grafana server at boot, enable the service
sudo systemctl enable grafana-server
Grafana should now be running.
Sign In
Open Web Browser
By default Grafana should be running on http://localhost:3000. If you installed Grafana on a different host than what you use to connect to it, replace "localhost" with the internal IP address of the host where Grafana was installed.
Credentials
The username and password is admin
.
When prompted, change the password to something more secure.
Once you have signed in you can begin adding data sources and creating dashboards.
Uninstall
If you ever want to uninstall Grafana, the steps are specified on the Grafana Wiki.
However they leave a few remnants of Grafana which I like to remove. These are the steps I typically take
Stop the service
sudo systemctl stop grafana-server
Purge Grafana
sudo apt-get remove --purge grafana
Remove Grafana directories:
sudo rm -rf /etc/grafana # Configuration files
sudo rm -rf /var/lib/grafana # Data storage (SQLite database, etc.)
sudo rm -rf /var/log/grafana # Log files
Remove residual dependencies
sudo apt-get autoremove
Remove the grafana.list
sudo rm /etc/apt/sources.list.d/grafana.list
Refresh your packages
sudo apt-get update
This should completely clear Grafana from your system.