Grafana dashboard tool to visualize time series data as well viewing more detailed log info. For this guide we will be deploying Grafana in docker to make it easy to update/change configs.
To get started, SSH to your docker host and create the config directory.
# BASH [Linux VM] mkdir /opt/containers && mkdir /opt/containers/grafana
Now copy the compose file down for Grafana.
# BASH [Linux VM] curl https://bin.alexsguardian.net/raw/grafana-compose -o /opt/containers/grafana/grafana-compose.yml
Then copy down the sample.ini file from https://github.com/grafana/grafana to create the grafana.ini file.
# BASH [Linux VM] curl https://raw.githubusercontent.com/grafana/grafana/master/conf/sample.ini -o /opt/containers/grafana/grafana.ini
Edit the grafana-compose.yml file and change the <CHANGE ME> section
# BASH [Linux VM] nano /opt/containers/grafana/grafana-compose.yml
After changing the admin password your variable should look like
Save and close the grafana-compose.yml file via
CTRL+X then Y. Once you are back in the terminal, we need set up the permissions for Grafana so it can read/write to the config directory.
# BASH [Linux VM] sudo chown -R 472:472 /opt/containers/grafana && ls -l /opt/containers/
Once you change the owner of the
/grafana directory you will need to use
sudo for all commands involving Grafana’s configs, etc.
Now restore the permissions on the
grafana-compose.yml file to your user.
# BASH [Linux VM] sudo chown youruser:youruser /opt/containers/grafana/grafana-compose.yml
# BASH [Linux VM] cd /opt/containers/grafana && docker-compose -f grafana-compose.yml up -d
After a few seconds Grafana should be deployed and accessible at
http://your-machine-ip:3000. Your admin user login should be
admin and the password you specified earlier.
Creating the InfluxDB Grafana user
Since Grafana will be communicating directly to InfluxDB, we should probably make sure its doing so in a read only state… for security purposes.
# BASH [Linux VM] curl -XPOST http://localhost:8086/query -u root:password --data-urlencode "q=CREATE USER grafana WITH PASSWORD 'password'" curl -XPOST http://localhost:8086/query -u root:password --data-urlencode "q=GRANT READ ON telegraf TO grafana"
You can check the new users permissions via the
SHOW GRANTS FOR user query seen above.
Creating the Telegraf dashboard
Open a web browser session and navigate to
http://your-docker-machine-ip:3000. Then login with the username and password you setup earlier. Once logged in you should see something similar to the below image.
Click on the settings cog on the left side and click
Add data source and select InfluxDB from the list of options.
Fill out the following info:
http://influxdb_influx_1:8086(replace influxdb_influx_1 with the name of your influxdb container name)
grafana password(you specified this in the above section when creating the user account for influxdb)
Save & Test then
Now hover over the
+ on the left side and click Import. Type
10409 into the Grafana.com Dashboard box and click
InfluxDB [Telegraf] in the drop down box next to ‘telegraf’.
Welcome to your first Grafana dashboard! To make it auto refresh, select the down arrow in the top right next to the refresh button and select
Now that you have your first dashboard up and running, feel free to check out some of my posts on various things you can monitor in your homelab!
Head back to the start page and look at the Add-ons ToC section!