At its core, Grafana runs as a web server, and as such, it is not a typical double-click application. You will need to be comfortable with the command line and have administrator privileges on the computer you plan to install Grafana on. To download the latest versions of Grafana, check out https://grafana.com/grafana/download.
The Grafana application server runs on *nix operating systems (Linux, OS X,and Windows), and it can be installed locally on a laptop or workstation or on a remote server. It is even available as a hosted application if you'd rather not deal with setting up or managing a server application on your own.
In this section, we'll walk through the most typical installation options:
- Docker
- OS X
- Linux
- Windows
- Hosted Grafana on the cloud
Once you've completed the installation of your choice, proceed to the Connecting to the Grafana serversectionfor instructions on how to access Grafana from a web browser.
Grafana in a Docker container
The easiest and least complex installation method is to run Grafana from within a Docker container. Docker is available for all major platforms and can be downloaded by visitinghttps://www.docker.com/.
After installing Docker, open a terminal window and type in the following command:
$ docker run -d --name=grafana -p 3000:3000 grafana/grafana
Docker will automatically download and run the latest version of Grafana for your computer's architecture. Bear in mind that since this basic container has no persistent storage, nothing will be retained if you delete the container. I suggest you run the container with a temporary volume so that Grafana's internal database will continue to exist, even if you destroy the container:
$ docker volume create grafana-storage
$ docker run -d --name = grafana -p 3000:3000\
-v grafana-storage:/var/lib/grafana \
grafana/grafana
I recommend proceeding with Docker for the purposes of this book as it will allow an almost turnkey installation experience, as all the necessary dependencies will be automatically downloaded with the container. It will also install in its own sandbox, so you don't need to worry about installing a stack of software that will be difficult to delete later. Finally, in future chapters we will be setting up data sources using similar Docker containers, so managing the data pipeline as a combination of containers will be very consistent and straightforward.
Grafana for OS X
There are two options for installing and running Grafana for OS X:
- Homebrew
- The command line
Using Homebrew is the simplest option as it wraps all the installation chores in a single command. To get Homebrew, visit https://brew.sh/. If you want more control over where to install Grafana, the command line option is a better choice.
Homebrew
To install via Homebrew, use the following:
$ brew install grafana
If you want to keep Grafana running even after a reboot, use theservices subcommand to launch the installed Grafana application as a service. You will first need to confirm services installation:
$ brew tap homebrew/services
$ brew services start grafana
The command line
To install via the command line, open a Terminal shell window and download an OS X distribution tarball, thenuntarit into the directory of your choice (replace $GRAFANA_VERSION with the current version):
$ wget https://dl.grafana.com/oss/release/grafana-$GRAFANA_VERSION.darwin-amd64.tar.gz
$ tar -zxvf grafana-$GRAFANA_VERSION.darwin-amd64.tar.gz
Once you'veuntared the file,cdinto the directory and launch the binary:
./bin/grafana-server web
Grafana for Linux
Linux comes in a number of flavors and each has a slightly different installation system. Typically, you download the binary and then run the installer on the package file. To get the latest Grafana binaries for Linux, visit https://grafana.com/grafana/download?platform=linux.
RedHat Linux
The installer for the RedHat distributions (CentOS, RedHat, and Fedora) isyum. To download and install (replacing $GRAFANA_VERSION with the current version), use the following:
$ wget https://dl.grafana.com/oss/release/grafana-$GRAFANA_VERSION.x86_64.rpm
$ sudo yum install initscripts urw-fonts
$ sudo yum localinstall grafana-$GRAFANA_VERSION.x86_64.rpm
To start up Grafana, usesystemd:
$ systemctl daemon-reload
$ systemctl start grafana-server
$ systemctl status grafana-server
To keep Grafana running even after a reboot, use the following:
$ sudo systemctl enable grafana-server.service
Debian Linux
The installer for the Debian distributions (Debian and Ubuntu) isdpkg. To download and install (replace $GRAFANA_VERSION with the current version), use the following:
$ wget https://dl.grafana.com/oss/release/grafana_$GRAFANA_VERSION_amd64.deb
$ sudo apt-get install -y adduser libfontconfig1
$ sudo dpkg -i grafana_$GRAFANA_VERSION_amd64.deb
To start up Grafana, use the following:
$ systemctl daemon-reload
$ systemctl start grafana-server
$ systemctl status grafana-server
To keep Grafana running even after a reboot, use the following:
$ sudo systemctl enable grafana-server.service
Grafana for Windows
Installation for Windows is straightforward:
- Go to https://grafana.com/grafana/download?platform=windows.
- Download the latest MSI installer file from the download link.
- Launch the.msifile to install.
Hosted Grafana on the cloud
If you would rather not install Grafana on your computer, or you don't have access to a computer that can run Grafana, there is another option—Grafana can host a free instance for you. There are restrictions—namely that in order to access a data source, you will need to upgrade a paid subscription—but if you want to follow this book up to the point where we use data sources, hosted Grafana might be a good solution. To sign up for the hosted version, go to https://grafana.com/get and select the link under We Host It.