Notes on installation and configuration of Grafana via Saltstack for future me. This a companion for a previous post, I covered how I istalled Prometheus and node_exporter on my machines via Salt. Grafana povides convienient dashboards through which to visualize data collected by Prometheus (and other tools).
Installation
Grafana is not an officially supported package on on Arch Linux, yet that is the platform on which I will be running it from, so I am opting to install standalone Linux binaries for ARM64, which were retrieved according to the directions on the Grafana website.
At this point it is simply a matter of issuing the command ./bin/grafana-server from the install directory grafana-8.3.3 and then visiting the Grafana portal in a web browser pointed to the server where installed on port 3000.
After logging into Grafana, setting a non default password, and setting up a Datasource connection to my Prometheus server, dashboards like the following become available.
Automating Installation with Salt
While the manual install wasn’t bad, as always I like to script the install so I can repeat it in the future without having to remember or research all the steps again. I use Salt as my home orcheststration tool and the files below are what I am using to install and configure Grafana so that it runs as a service restarting automatically and when the machine restarts.
The state file I created has been aded to the base file of the machine on which it is installed, and will be included if I rebuild the machine. The state can also be used to install on additional machines if needed, and will provide an easy foundation on which to script instalations of newer versions and to other platforms.
While there is clearly room for improvement in my approach, the below meets my needs of the moment, and as a thought leader once explained to me, “up and running always beats upcoming”.
With no further ado, the command I use to instll Grafana with the below Salt state and configuration files is su -c 'salt ceed-chuck state.apply app_grafana test=False'.
Of course I failed to capture output from the initial install, so all I can offer is the output of a second run which found everything in place and as expected and so made no actual changes.
Salt app_grafana
File system layout for app_grafana
init.sls
This is the file that does all the installation and configuration work on the Salt minion.
grafana-server.service
This is the SystemD service file I am using currently. It is almost exactly as on Grafana GitHub for RPM packaging, with changes to EnvironmentFile=, WorkingDirectory=, and ExecStart= settings to mat my install location and personal preferences.
grafana-server
This is the file that sets the environment variables used by the grafana-server.service for Systemd to start the service using my desired paths and configuration files.
Chrls is currently a technology transformation leader at one of the oldest American investment banking services holding companies, headquartered in New York City. Previous roles at current employer include project manager, front office support, retail and enterprise global Windows server support. Currently residing in Tennessee on the Cumberland Plateau and enjoying life, family and open source.