A simple Express.js service that exports Grafana table panels to PDF. Supports Thai language out of the box.
Grafana doesn't have native PDF export for table panels. This service fills that gap — just call the API with your dashboard UID and panel ID, get a PDF back.
- Direct Grafana API integration
- PDF generation with pdfmake
- Thai language support (TH Sarabun New font)
- Works with PostgreSQL and Infinity datasources
- Date range filtering
- Template variable support
# Clone
git clone https://github.com/VoodooVortex/grafana-table-exporter.git
cd grafana-table-exporter
# Install
npm install
# Configure
cp .env.example .env
# Edit .env with your Grafana URL and API key
# Run
npm startCreate a .env file:
PORT=4000
GRAFANA_URL=https://your-grafana-instance.com
GRAFANA_API_KEY=Bearer your-api-key-hereRequired:
dashboardUid— Dashboard UIDpanelId— Table panel ID
Optional:
from/to— Date range (ISO or Unix timestamp)reportType—defaultoraudit_logvar-*— Template variables (e.g.,var-region=north)
curl -o report.pdf "http://localhost:4000/export-table-pdf?dashboardUid=abc123&panelId=4"With date range:
curl -o report.pdf "http://localhost:4000/export-table-pdf?dashboardUid=abc123&panelId=4&from=2024-01-01&to=2024-01-31"src/
├── app.js # Express setup
├── server.js # Entry point
├── config/ # Environment config
├── controllers/ # Request handlers
├── services/
│ ├── grafana.service.js # Grafana API client
│ ├── pdf.service.js # PDF generation
│ └── report.service.js # Orchestration
└── utils/ # Helpers
PostgreSQL — Executes raw SQL from panel config. Supports $__timeFilter() and variable interpolation.
Infinity — Fetches from external REST APIs. Handles custom headers and query params.
| Type | Columns |
|---|---|
default |
No, DateTime, Event Type, Device Name, Event |
audit_log |
No, DateTime, User, Object Name, Log Function, Description |
PRs welcome. Fork, branch, commit, push, open PR.
MIT — use freely, just keep the copyright notice.
Built with pdfmake, Express, and TH Sarabun New font.
