Create a grafana-oss (open source version) server.
git clone https://github.com/and-mora/expenses-monitor.git
cd expenses-monitor/grafana/
docker stack deploy --compose-file docker-compose.yml grafana
The .github/workflows/deploy-grafana.yml
action provides to deploy the grafana server on your VM.
It's required to set the following secrets on the repository:
VM_HOST
VM_PORT
VM_USERNAME
VM_PRIVATE_KEY
Add the docker secret relative to database password:
- default username (see here):
grafana_user
- add password secret to docker swarm
read -sp 'Enter password: ' PASS echo $PASS | docker secret create DB_GRAFANA_PASSWORD -
Grafana expects to have certificate and private key in /etc/letsencrypt/live/*
directory.
Customize the docker-compose if you have it in another directory.
Official grafana documentation here
Important! Ensure the correct permission on the files to be used by Grafana. In case of docker you can use the 472 user id (it's the one used by grafana) to grant the correct permission.
sudo chown 472:472 /etc/letsencrypt/*
sudo chmod -R g+rx /etc/letsencrypt/*
To configure a Gmail account as SMTP server read the following: https://community.grafana.com/t/setup-smtp-with-gmail/85815 and https://support.google.com/accounts/answer/185833?hl=en
You need to add the app password in the following secret in docker environment:
GMAIL_PASSWORD
The script init.sh
will create one user with view only permission and change the admin password from the default one.
It must be executed only on new installation.
- Run the init script with the command
sh init.sh <VIEWER_NAME> <VIEWER_EMAIL> <VIEWER_PASSWORD> <ADMIN_PASSWORD>
Log in the viewer-only account with the credentials: VIEWER_EMAIL
- VIEWER_PASSWORD
.
Log in the admin account with the credentials: admin
- ADMIN_PASSWORD
.
The dashboard reporter plugin it's provisioned with the application and allow to generate a pdf report from a dashboard. A service account must be created into the Grafana server and unfortunately atm it's not possible to provision it.
It's necessary to manually create the service account with Grafana UI and configure user to allow token generation. The token will be created on the flight to run the scheduled action and will have low expire date.
docker stack rm grafana
docker volume rm grafana_storage
docker compose up -d
docker compose down