docker-apps/grafana/grafana_jm.txt
2025-04-03 22:57:52 +02:00

81 lines
2.8 KiB
Plaintext

Create user and group
---------------------
Credentials -> Local Users -> Add
Full Name: grafana
Username: grafana
Disable Password: <selected>
Email: <leave empty>
Create New Primary Group: <selected>
Create Home Directory: <unchecked>
Samba Authentication: <unchecked>
Save
grafana UID: 3022
grafana GID: 3021
Create datasets
---------------
# In Truenas shell:
# list datasets
zfs list | grep -i "docker.*grafana"
# create following datasets if not present
zfs create SSD1/docker/data/grafana
zfs create SSD1/docker/data/grafana/appdata
chown -R git:git /mnt/SSD1/docker/data/grafana
Create folder
-------------
# In Truenas shell:
mkdir /mnt/SSD1/docker/stacks/grafana
Copy folder to docker stacks
----------------------------
In Windows cmd shell in grafana parent (apps) folder, enter:
./cp2nas 10.0.0.20 grafana
# or
pscp -P 22 -r grafana/stacks/*.* root@10.0.0.20:/mnt/SSD1/docker/stacks/grafana/
Creating secrets
----------------
# This can be skipped, but if skipped it requires commenting out ADMIN_PASSWORD and GF_USERS_ALLOW_SIGN_UP in .env file as well as sign on as user:admin/pw:admin at first access of grafana
In Truenas shell:
cd /mnt/SSD1/docker/stacks/grafana/secrets/
echo -n 'your_admin_password' > /mnt/SSD1/docker/stacks/grafana/secrets/grafana_admin_password
# restrict access
chown -R grafana:grafana /mnt/SSD1/docker/stacks/grafana/secrets/
chmod -R 400 /mnt/SSD1/docker/stacks/grafana/secrets/
# NB! if you want to remove all acl entries from a folder recursively, use setfacl -b -R <foldername>
# to list secrets in secrets dir
cd /mnt/SSD1/docker/stacks/grafana/secrets
for i in $(ls -1); do echo $i = `cat $i`; done | sort
#
# NB! this is not a means to change the admin password after grafana was accessed.
# To force admin password change by means of the above, you will have to clear the contents /mnt/data/grafana/appdata folder whilst grafana is down/stopped.
# WARNING: Deleting contents of /mnt/data/grafana/appdata folder will also remove the grafana database
Start Grafana
-------------
Refresh Dockge
Start Grafana
Log in to grafana at https://grafana.sthome.org
Enter username: admin / password: (if creating secrets was skipped, pw=admin)
Change login password if requested
Go to Connections->Data sources
Add new data source
Click on Prometheus
Enter prometheus server URL: http://prometheus:9090
Under Authentication, select appropriate type, e.g. Basic authentication
Enter authentication detail
Click on Save & test
Open another tab and browse to https://grafana.com/grafana/dashboards/
Search for desired dashboard
Select dashboard
Scroll down to grab ID and copy to clipboard
On grafana, click on Dashboards in left pane
Click down arrow next to New, then Import
Paste ID into field left of "Load" then click on Load
Click on down arrow in InfluxDB textbox and select Prometheus
Click on Import