Skip to content

Export Grafana table panel data to PDF reports with Thai language support

License

Notifications You must be signed in to change notification settings

VoodooVortex/grafana-table-exporter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Grafana Table PDF Exporter

Node.js License: MIT

A simple Express.js service that exports Grafana table panels to PDF. Supports Thai language out of the box.

Diagram


Why?

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.

Features

  • 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

Quick Start

# 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 start

Configuration

Create a .env file:

PORT=4000
GRAFANA_URL=https://your-grafana-instance.com
GRAFANA_API_KEY=Bearer your-api-key-here

API

GET /export-table-pdf

Required:

  • dashboardUid — Dashboard UID
  • panelId — Table panel ID

Optional:

  • from / to — Date range (ISO or Unix timestamp)
  • reportTypedefault or audit_log
  • var-* — Template variables (e.g., var-region=north)

Example

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"

Project Structure

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

Datasources

PostgreSQL — Executes raw SQL from panel config. Supports $__timeFilter() and variable interpolation.

Infinity — Fetches from external REST APIs. Handles custom headers and query params.

Report Types

Type Columns
default No, DateTime, Event Type, Device Name, Event
audit_log No, DateTime, User, Object Name, Log Function, Description

Contributing

PRs welcome. Fork, branch, commit, push, open PR.

License

MIT — use freely, just keep the copyright notice.

Credits

Built with pdfmake, Express, and TH Sarabun New font.

About

Export Grafana table panel data to PDF reports with Thai language support

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published