PDF Report Generation
This guide explains how to configure automated PDF reports using the Auto Trigger feature. PDF reports allow you to visualize Elasticsearch query results with charts and deliver them on a schedule.
The schema defines the structure for configuring automated jobs.
Quick Start
To create a PDF report, add toPdf as your output format. The minimum configuration requires linking your data selections to chart entries.
Key principle: The variableName in your chart configuration must exactly match the variableName defined in your data selection.
Minimal Example
{
"$schema": "/api/asyncJobs/schema",
"name": "Daily Call Report",
"description": "PDF report with call duration chart",
"enabled": true,
"metadata": {
"schemaVersion": "2.0.0"
},
"schedule": {
"cron": "0 6 * * *"
},
"type": "user",
"pipeline": {
"sources": [
{
"dataSource": "es",
"variableName": "CallDurationOverTime",
"parameters": [
{ "index": "calls" },
{
"size": 0,
"query": {
"bool": {
"must": [{ "query_string": { "query": "attrs.type:call-end" } }]
}
},
"aggs": {
"agg": {
"date_histogram": {
"field": "@timestamp",
"fixed_interval": "1h"
}
}
}
}
]
}
],
"transform": {
"transformationType": "js",
"codeFunctionReference": ""
},
"output": {
"formats": [
{
"transformationType": "toPdf",
"parameters": {
"pageSize": "A4",
"orientation": "landscape",
"charts": [
{
"variableName": "CallDurationOverTime",
"chartTitle": "Call Duration Over Time"
}
]
}
}
]
},
"delivery": {
"channels": []
}
}
}
PDF-Specific Configuration
Page Settings
| Setting | Options | Description |
|---|---|---|
pageSize | A4, Letter, Legal | Page size: A4 (210 × 297 mm), Letter (8.5 × 11"), Legal (8.5 × 14") |
orientation | portrait, landscape | Page orientation: vertical or horizontal |
Chart Configuration
| Property | Required | Description |
|---|---|---|
variableName | Yes | Must match exactly the variableName from data selection |
chartTitle | No | Chart title displayed above the visualization |
chartType | No | Explicit visualization type (auto-inferred if omitted) |
maxLength | No | Maximum items to display (for list and table types) |
Automatic Chart Type Inference
When you omit the chartType property, the system analyzes your data and automatically selects the most appropriate visualization.
Chart Selection by Data Type
| Category | Condition | Chart |
|---|---|---|
| scalar | Single value | value |
| time-series | Nested buckets + nested value | multipleLine |
| time-series | Nested buckets only | stackedBar |
| time-series | No nesting | timedateBar |
| categorical | Nested + depth ≥ 2 | sunburst |
| categorical | Nested + depth < 2 | list |
| categorical | No nesting + ≤ 8 items | donut |
| categorical | No nesting + > 8 items | list |
| tabular | Tabular data | table |
| tuple | ≤ 8 items | donut |
| tuple | > 8 items | list |
| unknown | Fallback | value |
Tip: For most use cases, automatic inference produces optimal results. Only specify
chartTypeexplicitly when you need a specific visualization.
Complete Example
A comprehensive example showing a PDF report with multiple data sources, transformations, and delivery.
{
"$schema": "/api/asyncJobs/schema",
"name": "Daily Call Summary",
"description": "Comprehensive daily call metrics report",
"enabled": true,
"metadata": {
"schemaVersion": "2.0.0"
},
"schedule": {
"cron": "0 7 * * *"
},
"type": "user",
"pipeline": {
"sources": [
{
"dataSource": "es",
"variableName": "CallVolume",
"parameters": [
{ "index": "calls" },
{
"size": 0,
"query": {
"bool": {
"must": [{ "query_string": { "query": "attrs.type:call-end" } }]
}
},
"aggs": {
"daily": {
"date_histogram": {
"field": "@timestamp",
"calendar_interval": "day"
},
"aggs": {
"total_duration": { "sum": { "field": "duration" } }
}
}
}
}
]
},
{
"dataSource": "es",
"variableName": "AgentStats",
"parameters": [
{ "index": "calls" },
{
"size": 0,
"query": {
"bool": {
"must": [{ "query_string": { "query": "attrs.type:call-end" } }]
}
},
"aggs": {
"agents": {
"terms": { "field": "attrs.agent" },
"aggs": {
"calls": { "value_count": { "field": "duration" } },
"duration": { "avg": { "field": "duration" } }
}
}
}
}
]
}
],
"transform": {
"transformationType": "js",
"code": "return { callVolume: data[0], agentStats: data[1] };"
},
"output": {
"formats": [
{
"transformationType": "toPdf",
"parameters": {
"pageSize": "A4",
"orientation": "landscape",
"charts": [
{
"variableName": "CallVolume",
"chartTitle": "Daily Call Volume (Last 30 Days)",
"chartType": "timedateBar"
},
{
"variableName": "AgentStats",
"chartTitle": "Top Agents by Call Count",
"chartType": "list",
"maxLength": 10
}
]
}
},
{
"transformationType": "toCsv",
"parameters": {}
}
]
},
"delivery": {
"channels": ["email-reporting-team"]
},
"action": [
{
"type": "saveToEs",
"parameters": {
"stream": "daily-call-reports",
"timestampField": "@timestamp"
}
}
]
}
}
Best Practices
Follow these best practices for creating effective PDF reports:
-
Use descriptive variable names — Names like
CallDurationByHourare clearer thandata1 -
Let inference work for you — Only specify
chartTypewhen you need a specific visualization -
Match variable names exactly — Copy-paste to avoid typos between data selection and chart config
-
Use landscape for dashboards — Multiple charts display better in landscape orientation
-
Limit table rows — Use
maxLengthto keep table charts readable -
Test with Run Now — Validate your configuration immediately before scheduling
Troubleshooting
Common Issues
| Issue | Cause | Solution |
|---|---|---|
| Chart shows "No Data" | Variable name mismatch between data selection and chart configuration | Verify exact spelling and case of variableName |
| Wrong chart type displayed | Inference selected a different type than expected | Explicitly set chartType to override automatic inference |
| Chart type validation error | Explicit chartType is incompatible with the data structure | Use a compatible chart type or adjust your Elasticsearch query |
| PDF document is excessively long | Table chart has too many rows | Add maxLength property to limit the number of displayed rows |
See Also
- Pipeline Configuration - General configuration reference for data selection, transformations, output formats, delivery channels, and actions
- Create New Report - Getting started guide