Upgrading Grafana

Upgrading Grafana is something that we should do as new versions with new features become available. Because we have installed our system by downloading and running them as standalone binaries, the simple method such as using the apt-get track won’t work for us.

However, that doesn’t mean that it’s a difficult task.

In fact, we can make the process fairly straight forward and painless by installing the new version alongside our older version and then just copying over the configuration and database.

What we will do is;

  • Download and decompress our new version
  • Copy the configuration and data from our old version to our new version.
  • Stop our old version
  • Run our new version manually (not as a service) and test it.
  • Stop the newer version
  • Change the directory name of our old and new versions
  • Start the Grafana service.

Download

In much the same way that we installed Grafana the first time, the first thing we need to do is to find the right version of Grafana to download. To do this browse to the download page here - https://grafana.com/grafana/download?platform=arm. Look for the standalone binary for the ARMv7 version (assuming that we are installing on a Pi 2,3 or 4)

The download page noted above goes straight to the ARM download page. We will be looking for the ‘Standalone Linux Binaries’ for ARMv7. Note the name or copy the URL for the file that is presented. On the 2nd of February, the version that was available was 6.6. The previous version that I am upgrading from is 6.5.3. The full URL for our new version is this https://dl.grafana.com/oss/release/grafana-6.6.0.linux-armv7.tar.gz;

On our Pi we will start the process in the pi users home directory (/home/pi/). We will initiate the download process with the wget command as follows;

The file that is downloaded is compressed so once the download is finished we will want to expand our file;

Remove the original compressed file with the rm (remove) command;

We now have a directory called grafana-6.6.0. Previously we would have renamed this with the mv (move) command to rename the directory to just ‘grafana’. However, in this case we will work with our new version in its folder grafana-6.6.0.

Stop the old version

Stopping the Grafana service means that we need to think a bit about some implications. While we have the program stopped, there won’t be any alerting or dynamically updating graphs. If we have other users that are relying on the service to be operating we will need to ensure that we discuss the plans with them ahead of time.

Stopping the service is nice and easy;

Copy the configuration and data

The two things that we will want to copy over are the configuration changes and the database.

Since we haven’t started our new version of Grafana yet, it won’t have a data folder, so we can just copy that straight into the appropriate place.

To be on the safe side, we can rename the current, new configuration directory so that we have it there if something goes awry.

Then copy in our configuration from our current Grafana instance

Run the new version manually and test

We can now run Grafana manually

To test that it is working correctly, we can open our browser to the Grafana desktop and check that all the things that are in there seem good. Once we are happy we can move on.

Stop the newer version

In your terminal use ‘ctrl-c’ to stop the running manual instance of grafana-server.

Change the directory names

Now that we’re happy that everything is in order we can change the name of our older Grafana instance to reflect its version number (in other words, we won’t get rid of it just yet, because it’s always prudent to keep things about just in case.

And now we can rename the directory of our new version of Grafana as simply grafana.

Start the Grafana service.

With everything in it’s proper place we can restart the service again and it will automatically start our new version.

Just as a final check, we should go back to our browser and go over the system to confirm that everything is good.

If you have any users of the system you can advise them that everything is operating well again.