independent service for generating PDF based on Grafana dashboards, developed mainly for CentOS 7, but might work on different distros/OS with small tweaks.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
For docker-based installation:
CentOS 7, docker, docker-compose
For regular Python-app installation:
CentOS 7, docker, docker-compose, Python3.6+, venv
Clone repository
git clone https://github.com/lasagnu/GrafanaToPDF/
Enter the dir with reporter:
cd grafana-pdf-reporter/
Make it possible to execute wkhtmltopdf_setup.sh
chmod +x wkhtmltopdf_setup.sh
Execute the script and allow wkhtmltopdf to be installed locally
./wkhtmltopdf_setup.sh
Edit configuration file and provide the IP address and port of Grafana as well as the API key:
Config/__init__.py
Example:
class Grafana:
address = '192.168.0.1:3000'
api_key = 'BlAhBlAHblAhBlaHblahsdladOoPaDoOpAdOopAdoOpa=='
Simply run this command to build a container and mount it:
docker-compose -p CONTAINER_NAME up -d
Service should be available on the HOST_IP:5000 by default. It could be changed in the docker-compose.yml:
ports:
- "<host_port>:5000"
I would recommend to install the virtualenv first:
python3 -m venv venv
Once the virtual environment has been established, activate it by:
source venv/bin/activate
And install all dependencies:
pip install -r requirements.txt
Once installed you should be able to run it by using this command:
python3 app.py
Once the application is up and running, you should be able to generate the PDF with all panels of a dashboard by passing it's UID to the /dashboard endpoint:
localhost:5000/dashboard/<dashboard_uid>
You can view the generated raport once again by accessing the same /dashboard enpoint and passing the ID generated previously
example: localhost:5000/dashboard/1581089563394252
- Marek Mackiewicz - [email protected]